1.1 --- a/libxml2dom/macrolib/macrolib.py Fri Jun 20 21:46:24 2008 +0200
1.2 +++ b/libxml2dom/macrolib/macrolib.py Sat Sep 29 22:34:24 2007 +0000
1.3 @@ -85,6 +85,11 @@
1.4 and 'prefix'.
1.5 """
1.6
1.7 + # Special treatment for XML namespace.
1.8 +
1.9 + if prefix == "xml" and ns == xml.dom.XML_NAMESPACE:
1.10 + return libxml2mod.xmlSearchNsByHref(Node_ownerDocument(node), node, xml.dom.XML_NAMESPACE)
1.11 +
1.12 new_ns = None
1.13 current = libxml2mod.xmlNodeGetNsDefs(node)
1.14 while current is not None:
1.15 @@ -323,6 +328,9 @@
1.16 if prefix is None:
1.17 prefix = _get_invented_prefix(node, ns)
1.18 new_ns = _make_namespace(node, ns, prefix, set_default=0)
1.19 + # Remove any conflicting attribute.
1.20 + if Node_hasAttributeNS(node, ns, localName):
1.21 + Node_removeAttributeNS(node, ns, localName)
1.22 libxml2mod.xmlSetNsProp(node, new_ns, localName, value)
1.23 else:
1.24 # NOTE: Needs verifying: what should happen to the namespace?
1.25 @@ -504,6 +512,18 @@
1.26 PARSE_ERR = 81
1.27 SERIALIZE_ERR = 82
1.28
1.29 + def __repr__(self):
1.30 + return str(self)
1.31 +
1.32 + def __str__(self):
1.33 + exctype = self.args[0]
1.34 + if exctype == self.PARSE_ERR:
1.35 + return "Parse error: LSException(%d)" % exctype
1.36 + elif exctype == self.SERIALIZE_ERR:
1.37 + return "Serialize error: LSException(%d)" % exctype
1.38 + else:
1.39 + return Exception.__repr__(self)
1.40 +
1.41 # Utility functions.
1.42
1.43 def createDocument(namespaceURI, localName, doctype):