1.1 --- a/libxml2dom/macrolib/macrolib.py Sun Dec 11 20:27:20 2005 +0000
1.2 +++ b/libxml2dom/macrolib/macrolib.py Sun Dec 11 20:28:08 2005 +0000
1.3 @@ -27,6 +27,14 @@
1.4 else:
1.5 return s
1.6
1.7 +def get_ns(ns):
1.8 + out_ns = to_unicode(libxml2mod.xmlNodeGetContent(ns))
1.9 + # Detect "" and produce None as the empty namespace.
1.10 + if out_ns:
1.11 + return out_ns
1.12 + else:
1.13 + return None
1.14 +
1.15 def _get_prefix_and_localName(name):
1.16 t = name.split(":")
1.17 if len(t) == 1:
1.18 @@ -80,7 +88,7 @@
1.19 while node is not None:
1.20 ns = libxml2mod.xmlNodeGetNs(node)
1.21 if ns is not None:
1.22 - attributes[(libxml2mod.xmlNodeGetContent(ns), libxml2mod.name(node))] = node
1.23 + attributes[(get_ns(ns), libxml2mod.name(node))] = node
1.24 else:
1.25 attributes[(None, libxml2mod.name(node))] = node
1.26 node = libxml2mod.next(node)
1.27 @@ -89,7 +97,7 @@
1.28 def Node_namespaceURI(node):
1.29 ns = libxml2mod.xmlNodeGetNs(node)
1.30 if ns is not None:
1.31 - return to_unicode(libxml2mod.xmlNodeGetContent(ns))
1.32 + return get_ns(ns)
1.33 else:
1.34 return None
1.35
1.36 @@ -351,7 +359,11 @@
1.37 # NOTE: Fixed to use version 1.0 only.
1.38 d = libxml2mod.xmlNewDoc("1.0")
1.39 if localName is not None:
1.40 - root = Node_createElementNS(d, namespaceURI, localName)
1.41 + # NOTE: Verify that this is really what should occur.
1.42 + if namespaceURI is not None:
1.43 + root = Node_createElementNS(d, namespaceURI, localName)
1.44 + else:
1.45 + root = Node_createElement(d, localName)
1.46 Node_appendChild(d, root)
1.47 if doctype is not None:
1.48 libxml2mod.xmlCreateIntSubset(d, doctype.localName, doctype.publicId, doctype.systemId)