
Hi Noah, Noah Slater wrote:
On 29/05/06, Noah Slater <nslater@gmail.com> wrote:
I noticed today that certain child attribute values are mangled when you try to insert/append child elements onto parent elements.
I have written a test script for this as usual.
I have just noticed that if you set the attributes after you have added to the tree the weird bug does not happen.
Thanks for reporting this. It looks like a bug in libxml2, as it only happens for "xml:id", not for other attributes. I guess the bug is in xmlReconciliateNs, but that's really just guessing. A simpler way to reproduce this is: ------------------------------- root = etree.Element('element') subelement = etree.Element('subelement') subelement.set("{http://www.w3.org/XML/1998/namespace}id", "foo") root.append(subelement) print etree.tostring(root) ------------------------------- What surprises me most is that ElementTree (1.2.6) has a similar bug. It returns this for subelement.attrib after appending: {'{}id': 'foo'} I'll file a bug report on libxml2 anyway. Stefan