Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: hazen [...] cs.columbia.edu
Cc:
AdminCc:

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



Subject: Document->importNode() moves instead of copies subtrees
Download (untitled) / with headers
text/plain 3.7k
I've found what looks to be a bug with XML::LibXML::Document->importNode. Not sure if this is more directly a bug with libxml2, but since I found it while using this module, thought I'd report here. Problem: importNode seems to be acting like adoptNode; The original node is affected by the operation (there is a move, not a copy going on), where the W3C rec says it should not: http://www.w3.org/TR/DOM-Level-3-Core/core.html#Core-Document-importNode Example code: /=========== perl begin ============\ # # test of LibXML::Document->importNode method # use strict; use warnings; use XML::LibXML; # set up two documents my $dom1 = new XML::LibXML::Document->createDocument(); my $a1 = $dom1->createElement('a'); my $b1 = $dom1->createElement('b'); my $c1 = $dom1->createElement('c'); $dom1->setDocumentElement($a1); $a1->appendChild($b1); $a1->appendChild($c1); my $dom2 = new XML::LibXML::Document->createDocument(); my $a2 = $dom2->createElement('a'); $dom2->setDocumentElement($a2); # output documents print "Document 1:\n\n".$dom1->toString()."\n"; print "Document 2:\n\n".$dom2->toString()."\n"; # import (copy?! move?! SHOULD be copy) node from first document to second # http://www.w3.org/TR/DOM-Level-3-Core/core.html#Core-Document-importNode my $imp = $dom1->documentElement()->find('//c')->shift(); $dom2->importNode($imp); $a2->appendChild($imp); # output documents print "Document 1:\n\n".$dom1->toString()."\n"; print "Document 2:\n\n".$dom2->toString()."\n"; \============ perl end ==============/ Output from test example: /============ output begin ============\ Document 1: <?xml version="1.0"?> <a><b/><c/></a> Document 2: <?xml version="1.0"?> <a/> Document 1: <?xml version="1.0"?> <a><b/></a> Document 2: <?xml version="1.0"?> <a><c/></a> \============ output end ============/ Output *should* be: /============ output begin ============\ Document 1: <?xml version="1.0"?> <a><b/><c/></a> Document 2: <?xml version="1.0"?> <a/> Document 1: <?xml version="1.0"?> <a><b/><c/></a> Document 2: <?xml version="1.0"?> <a><c/></a> \============ output end ============/ Environment information: libxml2 2.5.4 XML::LibXML 1.53 perl... Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Platform: osname=solaris, osvers=2.8, archname=sun4-solaris uname='sunos diamond.cs.columbia.edu 5.8 generic_108528-18 sun4u sparc sunw,ultra-2 ' config_args='-Dprefix=/home/aquaint/solaris/perl -Uinstallusrbinperl -d' hint=previous, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='/opt/SUNWspro/bin/cc', ccflags ='-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O', cppflags='-I/usr/local/include -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccversion='WorkShop Compilers 5.0 98/12/15 C 5.0', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='/opt/SUNWspro/bin/cc', ldflags =' -L/usr/local/lib ' libpth=/usr/local/lib /opt/SUNWspro/SC5.0/bin/../lib /opt/SUNWspro/SC5.0/bin /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldb -ldl -lm -lc perllibs=-lsocket -lnsl -ldl -lm -lc libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-KPIC', lddlflags='-G -L/usr/local/lib'


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.