示例#1
0
        handler.characters(node.nodeValue)

      elif node.nodeType == Node.DOCUMENT_NODE:
        handler.startDocument()
        for child in node.childNodes: dom2sax(child, handler, nsmap)
        handler.endDocument()

      elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE:
        for child in node.childNodes: dom2sax(child, handler, nsmap)

      else:
        # ATTRIBUTE_NODE
        # ENTITY_NODE
        # PROCESSING_INSTRUCTION_NODE
        # COMMENT_NODE
        # DOCUMENT_TYPE_NODE
        # NOTATION_NODE
        pass

    return locals()


# The actual means to get a module!
getDomModule = moduleFactoryFactory(getDomBuilder)


# Keep backwards compatibility with things that directly load
# classes/functions from this module
for key, value in list(getDomModule(minidom).__dict__.items()):
	globals()[key] = value
示例#2
0
        return "".join(rv)

    class TreeBuilder(_base.TreeBuilder):
        documentClass = Document
        doctypeClass = DocumentType
        elementClass = Element
        commentClass = Comment
        fragmentClass = DocumentFragment

        def testSerializer(self, element):
            return testSerializer(element)

        def getDocument(self):
            if fullTree:
                return self.document._element
            else:
                if self.defaultNamespace is not None:
                    return self.document._element.find("{%s}html" %
                                                       self.defaultNamespace)
                else:
                    return self.document._element.find("html")

        def getFragment(self):
            return _base.TreeBuilder.getFragment(self)._element

    return locals()


getETreeModule = moduleFactoryFactory(getETreeBuilder)
示例#3
0
        elif node.nodeType == Node.DOCUMENT_NODE:
            handler.startDocument()
            for child in node.childNodes:
                dom2sax(child, handler, nsmap)
            handler.endDocument()

        elif node.nodeType == Node.DOCUMENT_FRAGMENT_NODE:
            for child in node.childNodes:
                dom2sax(child, handler, nsmap)

        else:
            # ATTRIBUTE_NODE
            # ENTITY_NODE
            # PROCESSING_INSTRUCTION_NODE
            # COMMENT_NODE
            # DOCUMENT_TYPE_NODE
            # NOTATION_NODE
            pass

    return locals()


# The actual means to get a module!
getDomModule = moduleFactoryFactory(getDomBuilder)

# Keep backwards compatibility with things that directly load
# classes/functions from this module
for key, value in list(getDomModule(minidom).__dict__.items()):
    globals()[key] = value
示例#4
0
    
        return "".join(rv)
    
    class TreeBuilder(_base.TreeBuilder):
        documentClass = Document
        doctypeClass = DocumentType
        elementClass = Element
        commentClass = Comment
        fragmentClass = DocumentFragment
    
        def testSerializer(self, element):
            return testSerializer(element)
    
        def getDocument(self):
            if fullTree:
                return self.document._element
            else:
                if self.defaultNamespace is not None:
                    return self.document._element.find(
                        "{%s}html"%self.defaultNamespace)
                else:
                    return self.document._element.find("html")
        
        def getFragment(self):
            return _base.TreeBuilder.getFragment(self)._element
        
    return locals()


getETreeModule = moduleFactoryFactory(getETreeBuilder)