当前位置: 首页>>代码示例>>Python>>正文


Python Node.DOCUMENT_NODE属性代码示例

本文整理汇总了Python中xml.dom.minidom.Node.DOCUMENT_NODE属性的典型用法代码示例。如果您正苦于以下问题:Python Node.DOCUMENT_NODE属性的具体用法?Python Node.DOCUMENT_NODE怎么用?Python Node.DOCUMENT_NODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在xml.dom.minidom.Node的用法示例。


在下文中一共展示了Node.DOCUMENT_NODE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: assert_recursive_equal

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import DOCUMENT_NODE [as 别名]
def assert_recursive_equal(self, doc, doc2):
        stack = [(doc, doc2)]
        while stack:
            n1, n2 = stack.pop()
            self.assertEqual(n1.nodeType, n2.nodeType)
            self.assertEqual(len(n1.childNodes), len(n2.childNodes))
            self.assertEqual(n1.nodeName, n2.nodeName)
            self.assertFalse(n1.isSameNode(n2))
            self.assertFalse(n2.isSameNode(n1))
            if n1.nodeType == Node.DOCUMENT_TYPE_NODE:
                len(n1.entities)
                len(n2.entities)
                len(n1.notations)
                len(n2.notations)
                self.assertEqual(len(n1.entities), len(n2.entities))
                self.assertEqual(len(n1.notations), len(n2.notations))
                for i in range(len(n1.notations)):
                    # XXX this loop body doesn't seem to be executed?
                    no1 = n1.notations.item(i)
                    no2 = n1.notations.item(i)
                    self.assertEqual(no1.name, no2.name)
                    self.assertEqual(no1.publicId, no2.publicId)
                    self.assertEqual(no1.systemId, no2.systemId)
                    stack.append((no1, no2))
                for i in range(len(n1.entities)):
                    e1 = n1.entities.item(i)
                    e2 = n2.entities.item(i)
                    self.assertEqual(e1.notationName, e2.notationName)
                    self.assertEqual(e1.publicId, e2.publicId)
                    self.assertEqual(e1.systemId, e2.systemId)
                    stack.append((e1, e2))
            if n1.nodeType != Node.DOCUMENT_NODE:
                self.assertTrue(n1.ownerDocument.isSameNode(doc))
                self.assertTrue(n2.ownerDocument.isSameNode(doc2))
            for i in range(len(n1.childNodes)):
                stack.append((n1.childNodes[i], n2.childNodes[i])) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:38,代码来源:test_minidom.py

示例2: testPickledDocument

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import DOCUMENT_NODE [as 别名]
def testPickledDocument(self):
        doc = parseString("<?xml version='1.0' encoding='us-ascii'?>\n"
                    "<!DOCTYPE doc PUBLIC 'http://xml.python.org/public'"
                    " 'http://xml.python.org/system' [\n"
                    "  <!ELEMENT e EMPTY>\n"
                    "  <!ENTITY ent SYSTEM 'http://xml.python.org/entity'>\n"
                    "]><doc attr='value'> text\n"
                    "<?pi sample?> <!-- comment --> <e/> </doc>")
        s = pickle.dumps(doc)
        doc2 = pickle.loads(s)
        stack = [(doc, doc2)]
        while stack:
            n1, n2 = stack.pop()
            self.confirm(n1.nodeType == n2.nodeType
                    and len(n1.childNodes) == len(n2.childNodes)
                    and n1.nodeName == n2.nodeName
                    and not n1.isSameNode(n2)
                    and not n2.isSameNode(n1))
            if n1.nodeType == Node.DOCUMENT_TYPE_NODE:
                len(n1.entities)
                len(n2.entities)
                len(n1.notations)
                len(n2.notations)
                self.confirm(len(n1.entities) == len(n2.entities)
                        and len(n1.notations) == len(n2.notations))
                for i in range(len(n1.notations)):
                    # XXX this loop body doesn't seem to be executed?
                    no1 = n1.notations.item(i)
                    no2 = n1.notations.item(i)
                    self.confirm(no1.name == no2.name
                            and no1.publicId == no2.publicId
                            and no1.systemId == no2.systemId)
                    stack.append((no1, no2))
                for i in range(len(n1.entities)):
                    e1 = n1.entities.item(i)
                    e2 = n2.entities.item(i)
                    self.confirm(e1.notationName == e2.notationName
                            and e1.publicId == e2.publicId
                            and e1.systemId == e2.systemId)
                    stack.append((e1, e2))
            if n1.nodeType != Node.DOCUMENT_NODE:
                self.confirm(n1.ownerDocument.isSameNode(doc)
                        and n2.ownerDocument.isSameNode(doc2))
            for i in range(len(n1.childNodes)):
                stack.append((n1.childNodes[i], n2.childNodes[i])) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:47,代码来源:test_minidom.py

示例3: testPickledDocument

# 需要导入模块: from xml.dom.minidom import Node [as 别名]
# 或者: from xml.dom.minidom.Node import DOCUMENT_NODE [as 别名]
def testPickledDocument(self):
        doc = parseString("<?xml version='1.0' encoding='us-ascii'?>\n"
                    "<!DOCTYPE doc PUBLIC 'http://xml.python.org/public'"
                    " 'http://xml.python.org/system' [\n"
                    "  <!ELEMENT e EMPTY>\n"
                    "  <!ENTITY ent SYSTEM 'http://xml.python.org/entity'>\n"
                    "]><doc attr='value'> text\n"
                    "<?pi sample?> <!-- comment --> <e/> </doc>")
        for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
            s = pickle.dumps(doc, proto)
            doc2 = pickle.loads(s)
            stack = [(doc, doc2)]
            while stack:
                n1, n2 = stack.pop()
                self.confirm(n1.nodeType == n2.nodeType
                        and len(n1.childNodes) == len(n2.childNodes)
                        and n1.nodeName == n2.nodeName
                        and not n1.isSameNode(n2)
                        and not n2.isSameNode(n1))
                if n1.nodeType == Node.DOCUMENT_TYPE_NODE:
                    len(n1.entities)
                    len(n2.entities)
                    len(n1.notations)
                    len(n2.notations)
                    self.confirm(len(n1.entities) == len(n2.entities)
                            and len(n1.notations) == len(n2.notations))
                    for i in range(len(n1.notations)):
                        # XXX this loop body doesn't seem to be executed?
                        no1 = n1.notations.item(i)
                        no2 = n1.notations.item(i)
                        self.confirm(no1.name == no2.name
                                and no1.publicId == no2.publicId
                                and no1.systemId == no2.systemId)
                        stack.append((no1, no2))
                    for i in range(len(n1.entities)):
                        e1 = n1.entities.item(i)
                        e2 = n2.entities.item(i)
                        self.confirm(e1.notationName == e2.notationName
                                and e1.publicId == e2.publicId
                                and e1.systemId == e2.systemId)
                        stack.append((e1, e2))
                if n1.nodeType != Node.DOCUMENT_NODE:
                    self.confirm(n1.ownerDocument.isSameNode(doc)
                            and n2.ownerDocument.isSameNode(doc2))
                for i in range(len(n1.childNodes)):
                    stack.append((n1.childNodes[i], n2.childNodes[i])) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:48,代码来源:test_minidom.py


注:本文中的xml.dom.minidom.Node.DOCUMENT_NODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。