Re: [xml] ID already defined in 2.9.2



On 18/12/2014 22:48, Bruce Miller wrote:
If you remove the `xml:id` attribute, the ID will be immediately removed
from the document and you don't have to care about references.

Yeah, that's sounding like the safest approach,
both from the underlying programming and the
application's logic.

Anybody higher on the stack that thinks they
want to know what the id of the node _was_
will just be SOL! :>

I just made the following commit to libxml2 to fix the handling of ID attributes in xmlSetTreeDoc:

https://git.gnome.org/browse/libxml2/commit/?id=f54d6a929af2a570396f0595a0e29064c908c12e

Now, you can also remove a node with:

    XML::LibXML::Document->new->adoptNode($node);

By moving the node to separate document, its original attributes are still available and the redefinition warning is prevented. This is somewhat expensive, especially if you choose to create a new document for every node removed this way. The latter might be required to avoid id clashes in the "adopter" document.

Nick



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]