
Hi, On Mon, 2006-03-06 at 07:51 +0100, Stefan Behnel wrote:
Andreas Pakulat wrote:
[...]
'<main><elem xmlns="test"><sub xmlns:ns0="test"/></elem></main>'
Correct, that should not happen, as my patch calls the DOMWrap function on "elem" at the before last line. So I would assume the modified libxml2 function doesn't solve the problem.
However this works:
doc = fromstring("<ns0:elem xmlns:ns0=\"test\" />") [25285 refs] doc.append(Element("{test}sub")) [25285 refs] tostring(doc) '<ns0:elem xmlns:ns0="test"><ns0:sub/></ns0:elem>' [25285 refs]
So at least something works (my system lxml doesn't show this behaviour). However I think this is the normal ns-cleanup working and it doesn't fix the bug I reported with libxml...
Right, the Element() call should create an ns0 prefix, which is then merged with the existing one. So that should just work as before.
The function xmlDOMWrapReconcileNamespaces() does not try to eliminate namespace declarations for different namespace prefixes. This is due to QNames in attribute/element content. QNames need a corresponding ns-prefix to be in scope; thus Libxml2 tries to avoid automatic renaming of prefixes. Example: <x:foo xmlns:x="urn:test:FOO"> <y:bar xmlns:y="urn:test:FOO">y:myQNameValue</y:bar> </x:foo> An elimination of the ns-decl with the "y" prefix would break the QName. So if lxml does somehow create distinct ns-prefixes (I'm not familiar with lxml's mechanism here), then the current elimination mechanism won't be usefull. Regards, Kasimier