Skip Menu |

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 69520
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: yoreek [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: IDs of elements is lost when importing nodes
IDs of elements is lost when importing nodes from another document. When call method 'importNode' executed function 'xmlNodeCopy' from the library libxml2, which does not import IDs. Propose to replace the call "xmlNodeCopy" on "xmlDocNodeCopy" in the file "dom.c".
Subject: test_node_copy.pl
#!/usr/bin/perl use XML::LibXML; my $doc = XML::LibXML->load_xml(string => <<'EOT'); <root> <item xml:id="id1">item1</item> </root> EOT printf "id1: %s\n", $_ ? $_->textContent : 'not found' for $doc->getElementById('id1'); my $doc2 = XML::LibXML->createDocument( "1.0", "UTF-8" ); $doc2->setDocumentElement( $doc2->importNode( $doc->documentElement() ) ); printf "id1: %s\n", $_ ? $_->textContent : 'not found' for $doc2->getElementById('id1');
Subject: libxml.patch
diff -Nura libxml-libxml-perl-1.70.ds/dom.c libxml-libxml-perl-1.70.ds.fixed/dom.c --- libxml-libxml-perl-1.70.ds/dom.c 2009-10-05 23:20:27.000000000 +0300 +++ libxml-libxml-perl-1.70.ds.fixed/dom.c 2011-07-16 13:55:27.188208417 +0300 @@ -580,7 +580,7 @@ return_node = (xmlNodePtr) xmlCopyDtd((xmlDtdPtr) node); } else { - return_node = xmlCopyNode( node, 1 ); + return_node = xmlDocCopyNode( node, doc, 1 ); } }
Thanks! This was fixed in XML-LibXML-1.81 which was just uploaded to CPAN. I added your patch and a t/*.t file based on your test case.