Lines Matching refs:doc
19 "<!DOCTYPE doc PUBLIC 'http://xml.python.org/public'"
23 "]><doc attr='value'> text\n"
24 "<?pi sample?> <!-- comment --> <e/> </doc>")
30 return getDOMImplementation().createDocument(None, "doc", doctype)
33 doctype = getDOMImplementation().createDocumentType("doc", None, None)
50 doc = create_doc_without_doctype(doctype)
51 doctype.entities.item(0).ownerDocument = doc
52 doctype.notations.item(0).ownerDocument = doc
53 return doc
64 doc = Document()
65 self.assertFalse(doc.async_)
101 dom = parseString("<doc><foo/></doc>")
114 and root.toxml() == "<doc><element/><foo/></doc>"
126 and root.toxml() == "<doc><element/><foo/><element/></doc>"
139 "<doc><element/><foo/><bar/><element/></doc>"
144 dom = parseString("<doc/>")
445 def get_empty_nodelist_from_elements_by_tagName_ns_helper(self, doc, nsuri,
447 nodelist = doc.getElementsByTagNameNS(nsuri, lname)
451 doc = parseString('<doc/>')
453 doc, 'http://xml.python.org/namespaces/a', 'localname')
455 doc, '*', 'splat')
457 doc, 'http://xml.python.org/namespaces/a', '*')
459 doc = parseString('<doc xmlns="http://xml.python.org/splat"><e/></doc>')
461 doc, "http://xml.python.org/splat", "not-there")
463 doc, "*", "not-there")
465 doc, "http://somewhere.else.net/not-there", "e")
574 doc = parseString("<doc/>")
575 elem = doc.createElement("extra")
577 self.assertRaises(xml.dom.HierarchyRequestErr, doc.appendChild, elem)
579 doc.unlink()
602 doc = parseString("<doc a=''/>")
603 e = doc.documentElement
611 doc = parseString("<doc xmlns:a='http://xml.python.org/' a:b=''/>")
612 e = doc.documentElement
645 dom = parseString("<doc><foo/></doc>")
646 doc = dom.documentElement
647 self.assertTrue(doc.hasChildNodes())
648 dom2 = parseString("<doc/>")
673 dom = parseString("<doc attr='value'><foo/></doc>")
689 and clone.toxml() == '<doc attr="value"/>'
698 and clone.toxml() == '<doc attr="value"><foo/></doc>'
703 doc = parseString("<?xml version='1.0'?>\n"
705 "<!DOCTYPE doc [\n"
708 "<doc attr='value'/>")
709 doc2 = doc.cloneNode(0)
715 doc = parseString("<?xml version='1.0'?>\n"
717 "<!DOCTYPE doc [\n"
720 "<doc attr='value'/>")
721 doc2 = doc.cloneNode(1)
722 self.confirm(not (doc.isSameNode(doc2) or doc2.isSameNode(doc)),
724 self.confirm(len(doc.childNodes) == len(doc2.childNodes),
730 self.confirm(not doc.documentElement.isSameNode(doc2.documentElement),
732 if doc.doctype is not None:
737 self.confirm(not doc.doctype.isSameNode(doc2.doctype))
774 doc = create_doc_with_doctype()
775 clone = doc.doctype.cloneNode(1)
793 doc = create_doc_with_doctype()
794 clone = doc.doctype.cloneNode(0)
798 doc1 = parseString("<doc/>")
799 doc2 = parseString("<doc/>")
823 doc = parseString("<doc attr='value'/>")
824 attr = doc.documentElement.getAttributeNode("attr")
843 doc = parseString("<?target data?><doc/>")
844 pi = doc.firstChild
865 <doc>Don't let entities make you frown ⌣</doc>
908 doc = parseString("<doc/>")
909 root = doc.documentElement
910 root.appendChild(doc.createTextNode("first"))
911 root.appendChild(doc.createTextNode("second"))
915 doc.normalize()
921 doc.unlink()
923 doc = parseString("<doc/>")
924 root = doc.documentElement
925 root.appendChild(doc.createTextNode(""))
926 doc.normalize()
930 doc.unlink()
933 doc = parseString("<doc/>")
934 root = doc.documentElement
935 root.appendChild(doc.createTextNode("first"))
936 root.appendChild(doc.createTextNode("second"))
937 root.appendChild(doc.createElement("i"))
941 doc.normalize()
951 doc.unlink()
954 doc = parseString("<doc/>")
955 root = doc.documentElement
956 root.appendChild(doc.createTextNode("first"))
957 root.appendChild(doc.createTextNode(""))
961 doc.normalize()
969 doc.unlink()
972 doc = parseString("<doc/>")
973 root = doc.documentElement
974 root.appendChild(doc.createTextNode(""))
975 root.appendChild(doc.createTextNode("second"))
979 doc.normalize()
987 doc.unlink()
990 doc = parseString("<doc/>")
991 root = doc.documentElement
992 root.appendChild(doc.createElement("i"))
993 root.appendChild(doc.createTextNode(""))
994 root.appendChild(doc.createElement("i"))
998 doc.normalize()
1007 doc.unlink()
1010 doc = parseString("<doc/>")
1011 root = doc.documentElement
1012 root.appendChild(doc.createTextNode(""))
1013 root.appendChild(doc.createTextNode("second"))
1014 root.appendChild(doc.createTextNode(""))
1015 root.appendChild(doc.createTextNode("fourth"))
1016 root.appendChild(doc.createTextNode(""))
1020 doc.normalize()
1028 doc.unlink()
1031 doc = parseString("<doc>"
1047 "</doc>")
1048 root = doc.documentElement
1049 root.childNodes[0].appendChild(doc.createTextNode(""))
1050 root.childNodes[0].appendChild(doc.createTextNode("x"))
1051 root.childNodes[1].childNodes[0].appendChild(doc.createTextNode("x2"))
1052 root.childNodes[1].appendChild(doc.createTextNode("x3"))
1053 root.appendChild(doc.createTextNode(""))
1063 doc.normalize()
1090 doc.unlink()
1094 doc = parseString("<o>text</o>")
1095 text = doc.documentElement.childNodes[0]
1099 doc.unlink()
1102 doc = parseString("<o><i/>t</o>")
1103 node = doc.documentElement
1110 doc = parseString("<doc><?pi?>text?<elm/></doc>")
1111 root = doc.documentElement
1121 doc.unlink()
1124 doc = parseString(
1125 "<doc><elm1><elm2/><elm2><elm3/></elm2></elm1></doc>")
1126 root = doc.documentElement
1131 self.confirm(root.parentNode is doc and
1136 doc.unlink()
1139 doc = parseString("<doc><e/><e/></doc>")
1140 children = doc.childNodes
1148 doc.unlink()
1151 doc = parseString('<foo>€</foo>')
1152 self.assertEqual(doc.toxml(),
1154 self.assertEqual(doc.toxml('utf-8'),
1156 self.assertEqual(doc.toxml('iso-8859-15'),
1158 self.assertEqual(doc.toxml('us-ascii'),
1160 self.assertEqual(doc.toxml('utf-16'),
1175 doc.unlink()
1178 doc = parseString('<foo>€</foo>')
1179 self.assertEqual(doc.toxml(),
1181 self.assertEqual(doc.toxml(standalone=None),
1183 self.assertEqual(doc.toxml(standalone=True),
1185 self.assertEqual(doc.toxml(standalone=False),
1187 self.assertEqual(doc.toxml('utf-8', True),
1191 doc.unlink()
1224 def checkRenameNodeSharedConstraints(self, doc, node):
1226 self.assertRaises(xml.dom.NamespaceErr, doc.renameNode, node,
1228 doc2 = parseString("<doc/>")
1233 doc = parseString("<doc a='v'/>")
1234 elem = doc.documentElement
1239 attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "b")
1249 and attr.ownerDocument.isSameNode(doc)
1253 attr = doc.renameNode(attr, "http://xml.python.org/ns", "c")
1269 attr = doc.renameNode(attr, "http://xml.python.org/ns2", "p:d")
1288 attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "e")
1304 self.assertRaises(xml.dom.NamespaceErr, doc.renameNode, attr,
1306 self.checkRenameNodeSharedConstraints(doc, attr)
1307 doc.unlink()
1310 doc = parseString("<doc/>")
1311 elem = doc.documentElement
1314 elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "a")
1320 and elem.ownerDocument.isSameNode(doc))
1323 elem = doc.renameNode(elem, "http://xml.python.org/ns", "b")
1329 and elem.ownerDocument.isSameNode(doc))
1332 elem = doc.renameNode(elem, "http://xml.python.org/ns2", "p:c")
1338 and elem.ownerDocument.isSameNode(doc))
1341 elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "d")
1347 and elem.ownerDocument.isSameNode(doc))
1349 self.checkRenameNodeSharedConstraints(doc, elem)
1350 doc.unlink()
1355 doc = xml.dom.minidom.getDOMImplementation().createDocument(
1357 node = doc.createComment("comment")
1358 self.assertRaises(xml.dom.NotSupportedErr, doc.renameNode, node,
1360 doc.unlink()
1363 doc = parseString("<doc>a</doc>")
1364 elem = doc.documentElement
1369 elem.appendChild(doc.createTextNode("b"))
1371 elem.insertBefore(doc.createCDATASection("c"), text)
1375 splitter = doc.createComment("comment")
1377 text2 = doc.createTextNode("d")
1382 x = doc.createElement("x")
1388 x = doc.createProcessingInstruction("y", "z")
1399 doc = parseString("<doc><e/></doc>")
1400 elem = doc.documentElement
1409 doc = parseString("<doc>a<e/>d</doc>")
1410 elem = doc.documentElement
1414 elem.insertBefore(doc.createTextNode("b"), splitter)
1415 elem.insertBefore(doc.createCDATASection("c"), text1)
1416 return doc, elem, text1, splitter, text2
1418 doc, elem, text1, splitter, text2 = setup()
1424 doc, elem, text1, splitter, text2 = setup()
1430 doc, elem, text1, splitter, text2 = setup()
1437 doc = parseString(
1438 "<!DOCTYPE doc [\n"
1441 " <!ATTLIST doc id ID #IMPLIED \n"
1451 "]><doc id='name' notid='name' text='splat!' enum='b'"
1454 elem = doc.documentElement
1470 doc = parseString("<doc a1='v' a2='w'/>")
1471 e = doc.documentElement
1474 self.confirm(doc.getElementById("v") is None
1478 self.confirm(e.isSameNode(doc.getElementById("v"))
1482 self.confirm(e.isSameNode(doc.getElementById("v"))
1483 and e.isSameNode(doc.getElementById("w"))
1487 a3 = doc.createAttribute("a1")
1490 self.confirm(doc.getElementById("v") is None
1491 and e.isSameNode(doc.getElementById("w"))
1496 doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
1497 self.confirm(e.isSameNode(doc.getElementById("w"))
1503 doc = parseString("<doc"
1507 e = doc.documentElement
1510 self.confirm(doc.getElementById("v") is None
1514 self.confirm(e.isSameNode(doc.getElementById("v"))
1518 self.confirm(e.isSameNode(doc.getElementById("v"))
1519 and e.isSameNode(doc.getElementById("w"))
1523 a3 = doc.createAttributeNS(NS1, "a1")
1526 self.confirm(e.isSameNode(doc.getElementById("w")))
1530 self.confirm(doc.getElementById("v") is None)
1532 doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
1533 self.confirm(e.isSameNode(doc.getElementById("w"))
1539 doc = parseString("<doc"
1543 e = doc.documentElement
1546 self.confirm(doc.getElementById("v") is None
1550 self.confirm(e.isSameNode(doc.getElementById("v"))
1554 self.confirm(e.isSameNode(doc.getElementById("v"))
1555 and e.isSameNode(doc.getElementById("w"))
1559 a3 = doc.createAttributeNS(NS1, "a1")
1562 self.confirm(e.isSameNode(doc.getElementById("w")))
1566 self.confirm(doc.getElementById("v") is None)
1568 doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
1569 self.confirm(e.isSameNode(doc.getElementById("w"))
1572 def assert_recursive_equal(self, doc, doc2):
1573 stack = [(doc, doc2)]
1604 self.assertTrue(n1.ownerDocument.isSameNode(doc))
1610 doc = parseString(sample)
1612 s = pickle.dumps(doc, proto)
1614 self.assert_recursive_equal(doc, doc2)
1617 doc = parseString(sample)
1618 doc2 = copy.deepcopy(doc)
1619 self.assert_recursive_equal(doc, doc2)
1622 doc = create_doc_without_doctype()
1623 doc.appendChild(doc.createComment("foo--bar"))
1624 self.assertRaises(ValueError, doc.toxml)
1628 doc = parseString("<element xmlns=''>\n"
1630 doc2 = parseString(doc.toxml())
1643 doc = parse(tstfile)
1644 title_tag = doc.documentElement.getElementsByTagName("TITLE")[0]
1645 self.assertRaises( xml.dom.NotFoundErr, doc.removeChild, title_tag)
1646 num_children_before = len(doc.childNodes)
1647 doc.removeChild(doc.childNodes[0])
1648 num_children_after = len(doc.childNodes)
1654 doc = parse(tstfile)
1655 pi = doc.createProcessingInstruction("y", "z")
1660 doc = parseString(xml_str)
1662 doc.writexml(output)
1667 doc = parseString(xml_str)
1668 self.assertEqual(doc.toxml(), xml_str)
1672 doc = parseString(xml_str)
1673 self.assertEqual(doc.toprettyxml(),
1679 doc = parseString(xml_str)
1680 self.assertEqual(doc.toprettyxml(),