Beispiel #1
0
 def _initRootNode(self, docElementUri, docElementName):
     if not self._dt:
         self._dt = implementation.createDocumentType(docElementName,'','')
     self._ownerDoc = implementation.createDocument(docElementUri, docElementName, self._dt)
     before_doctype = 1
     for o_node in self._orphanedNodes:
         if o_node[0] == 'pi':
             pi = self._ownerDoc.createProcessingInstruction(
                 o_node[1],
                 o_node[2]
                 )
             if before_doctype:
                 self._ownerDoc.insertBefore(pi, self._dt)
             else:
                 self._ownerDoc.appendChild(pi)
         elif o_node[0] == 'comment':
             comment = self._ownerDoc.createComment(o_node[1])
             if before_doctype:
                 self._ownerDoc.insertBefore(comment, self._dt)
             else:
                 self._ownerDoc.appendChild(comment)
         elif o_node[0] == 'doctype':
             before_doctype = 0
     self._rootNode = self._ownerDoc
     self._nodeStack.append(self._rootNode)
     return
Beispiel #2
0
 def startDTD(self, doctype, publicID, systemID):
     if not self._rootNode:
         self._dt = implementation.createDocumentType(doctype, publicID, systemID)
         self._orphanedNodes.append(('doctype'))
     else:
         raise 'Illegal DocType declaration'
     return
Beispiel #3
0
 def _initRootNode(self, docElementUri, docElementName):
     if not self._dt:
         self._dt = implementation.createDocumentType(
             docElementName, '', '')
     self._ownerDoc = implementation.createDocument(docElementUri,
                                                    docElementName,
                                                    self._dt)
     before_doctype = 1
     for o_node in self._orphanedNodes:
         if o_node[0] == 'pi':
             pi = self._ownerDoc.createProcessingInstruction(
                 o_node[1], o_node[2])
             if before_doctype:
                 self._ownerDoc.insertBefore(pi, self._dt)
             else:
                 self._ownerDoc.appendChild(pi)
         elif o_node[0] == 'comment':
             comment = self._ownerDoc.createComment(o_node[1])
             if before_doctype:
                 self._ownerDoc.insertBefore(comment, self._dt)
             else:
                 self._ownerDoc.appendChild(comment)
         elif o_node[0] == 'doctype':
             before_doctype = 0
     self._rootNode = self._ownerDoc
     self._nodeStack.append(self._rootNode)
     return
Beispiel #4
0
 def startDTD(self, doctype, publicID, systemID):
     if not self._rootNode:
         self._dt = implementation.createDocumentType(
             doctype, publicID, systemID)
         self._orphanedNodes.append(('doctype'))
     else:
         raise 'Illegal DocType declaration'
     return
Beispiel #5
0
    def initState(self, ownerDoc=None):
        """
        If None is passed in as the doc, set up an empty document to act
        as owner and also add all elements to this document
        """
        if ownerDoc == None:
            dt = implementation.createDocumentType('', '', '')
            self._ownerDoc = implementation.createDocument('', None, dt)
            self._rootNode = self._ownerDoc
        else:
            self._ownerDoc = ownerDoc
            #Create a docfrag to hold all the generated nodes.
            self._rootNode = self._ownerDoc.createDocumentFragment()

        #Set up the stack which keeps track of the nesting of DOM nodes.
        self._nodeStack = []
        self._nodeStack.append(self._rootNode)
        self._currText = ''
        return
Beispiel #6
0
    def initState(self, ownerDoc=None):
        """
        If None is passed in as the doc, set up an empty document to act
        as owner and also add all elements to this document
        """
        if ownerDoc == None:
            dt = implementation.createDocumentType('', '', '')
            self._ownerDoc = implementation.createDocument('', None, dt)
            self._rootNode = self._ownerDoc
        else:
            self._ownerDoc = ownerDoc
            #Create a docfrag to hold all the generated nodes.
            self._rootNode = self._ownerDoc.createDocumentFragment()

        #Set up the stack which keeps track of the nesting of DOM nodes.
        self._nodeStack = []
        self._nodeStack.append(self._rootNode)
        self._currText = ''
        return