Andreas Pakulat wrote:
On 05.03.06 13:00:49, Stefan Behnel wrote:
Here is a trivial patch that simply calls the function after having copied an element between documents.
If I understand that correctly it should also work if I create a new Element (with a namespace) and insert it as child right?
If that is correct, than this doesn't help. I still get a an extra ns declaration:
print etree.tostring(tree) <elem xmlns="test"><subelem/></elem> [25296 refs] tree.append(etree.Element("{test}sub1")) [25296 refs] print etree.tostring(tree) <elem xmlns="test"><subelem/><ns0:sub1 xmlns:ns0="test"/></elem> [25296 refs] tree.append(etree.Element("{test}sub2")) [25296 refs] print etree.tostring(tree) <elem xmlns="test"><subelem/><ns0:sub1 xmlns:ns0="test"/><ns0:sub2 xmlns:ns0="test"/></elem>
If I'm not mistaken, this is the expected behaviour from my patch. The problem is that it only fixes the tree of the element itself, not the entire tree. If you added the tree itself to a new tree, it should fix the current douplication of namespaces that you saw. I know this is not quite what was intended, but could you check that this happens? That would tell us that the libxml2 function works so far. We'd then have to fix a way for calling it at the right place... Stefan