On Mon, Feb 28, 2005 at 11:45:34AM +0100, Kasimier Buchcik wrote:
> Jacek Konieczny wrote:
> >Hello,
> >
> >I have a big problem with libxml2 python bindings. The problem also
> >occurs in the C API, but it is easily fixable there (so it can be just
> >called a 'feature').
> >
> >Here is the test case (python code):
> >
> >import libxml2
> >doc=libxml2.parseDoc("<a xmlns='http://a/'><b xmlns='http://b/'/></a>")
> >a = doc.getRootElement()
> >b = a.children
> >print `doc.serialize()`
> >print "Ns of <b/>: %r" % (b.ns().content,)
> >b.setNs(a.ns())
> >print `doc.serialize()`
> >print "Ns of <b/>: %r" % (b.ns().content,)
> >
> >The output is:
> >'<?xml version="1.0"?>\n<a xmlns="http://a/";><b xmlns="http://b/"/></a>\n'
> >Ns of <b/>: 'http://b/'
> >'<?xml version="1.0"?>\n<a xmlns="http://a/";><b xmlns="http://b/"/></a>\n'
> >Ns of <b/>: 'http://a/'

[...]

> >
> >The biggest problem is, that I cannot fix that using only the Python
> >API. xmlNode.reconciliateNs() does nothing about that.
> 
> There was a bug in xmlSearchNsByHref, which caused xmlReconciliateNs
> to fail in this scenario. Fixed in CVS (tree.c 1.339).

After applying the patch on libxml2-2.6.17 the output is:

'<?xml version="1.0"?>\n<a xmlns="http://a/";><b xmlns="http://b/"/></a>\n'
Ns of <b/>: 'http://b/'
'<?xml version="1.0"?>\n<a xmlns="http://a/";><default:b xmlns="http://b/"; 
xmlns:default="http://a/"/></a>\n'
Ns of <b/>: 'http://a/'

That is a correct XML, but still does not satisfy me. A prefix has been
added to <b/> and the unneccessary namespace declaration is still there.
For my needs that is still unacceptable. I implement an XMPP
implementation and for backward-compatibility with many Jabber clients
I need to use default namespaces (no prefixes) in some places.

I think a function to remove (or override) namespace declaration from
a node is what I need and I will request it via Bugzilla.

Greet,
        Jacek
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to