1.1 --- a/tests/namespaces3.py Thu Dec 15 18:25:46 2005 +0000
1.2 +++ b/tests/namespaces3.py Thu Dec 15 18:26:14 2005 +0000
1.3 @@ -1,13 +1,45 @@
1.4 #!/usr/bin/env python
1.5
1.6 -import libxml2dom
1.7 +import libxml2dom, xml.dom.minidom
1.8 +
1.9 +def test(document, e):
1.10 + e.setAttributeNS("xxx", "yyy", "zzz")
1.11 + e.setAttributeNS("xxx", "yyy", "zzz")
1.12 + e.setAttributeNS("xxx", "x:yyy", "zzz")
1.13 + e.setAttributeNS("xxx", "x:yyy", "zzz")
1.14 + e2 = document.createElementNS("DAV:", "d:abc")
1.15 + e.appendChild(e2)
1.16 + e2.setAttributeNS(None, "pqr", "xyz")
1.17 + e2.setAttributeNS("DAV:", "qrs", "tuv")
1.18 + e3 = document.createElementNS(None, "def")
1.19 + e2.appendChild(e3)
1.20 + e3.setAttributeNS("DAV:", "fgh", "ijk")
1.21 + e3.setAttributeNS(None, "nop", "wxy")
1.22
1.23 document = libxml2dom.createDocument(None, "doc", None)
1.24 e = document.xpath("*")[0]
1.25 -e.setAttributeNS("xxx", "yyy", "zzz")
1.26 -e.setAttributeNS("xxx", "yyy", "zzz")
1.27 -e.setAttributeNS("xxx", "x:yyy", "zzz")
1.28 -e.setAttributeNS("xxx", "x:yyy", "zzz")
1.29 -print document.toString()
1.30 +test(document, e)
1.31 +print document.toString(prettyprint=1)
1.32 +
1.33 +document = xml.dom.minidom.getDOMImplementation().createDocument(None, "doc", None)
1.34 +e = document.documentElement
1.35 +test(document, e)
1.36 +print document.toprettyxml()
1.37 +
1.38 +try:
1.39 + from xml.dom.ext import PrettyPrint
1.40 + PrettyPrint(document)
1.41 +except ImportError:
1.42 + print "PrettyPrint not tested."
1.43 +
1.44 +try:
1.45 + import pxdom
1.46 + document = pxdom.getDOMImplementation("").createDocument(None, "doc", None)
1.47 + e = document.documentElement
1.48 + test(document, e)
1.49 + out = pxdom.getDOMImplementation("").createDOMSerializer()
1.50 + print out.writeToString(document)
1.51 +except ImportError:
1.52 + print "pxdom not tested."
1.53
1.54 # vim: tabstop=4 expandtab shiftwidth=4