Subject: | Bug in XML::LibXML (most probably in libxml2) |
Date: | Fri, 28 Sep 2007 08:38:23 +0400 |
To: | <bug-XML-LibXML [...] rt.cpan.org> |
From: | "Konstantin Sedov" <ksedov [...] swsoft.com> |
I) DESCRIPTION:
XPATH search works wrong when prefixes of NameSpaces registered by application and used by XML document are intersecting.
II) DETAILS:
Use perl script (1.pl):
============================
use XML::LibXML;
my $d = XML::LibXML->new()->parse_string(q~<x:a xmlns:x="http://x.com"><x1:a xmlns:x1="http://x1.com"/></x:a>~);
my $x = XML::LibXML::XPathContext->new;
$x->registerNs($ARGV[1], 'http://x.com');
$x->registerNs($ARGV[2], 'http://x1.com');
warn($x->findnodes($ARGV[0],$d->documentElement));
============================
Execute script with arguments like below. The first execution demonstrates bug. Pay attention that prefixes are registered back to front against in xml.
The second one works fine (just for comparison).
============================
[root@localhost libxml]# perl 1.pl '//x1:a/x:a' x1 x
Warning: something's wrong at 1.pl line 6.
[root@localhost libxml]#
[root@localhost libxml]# perl 1.pl '//y1:a/y:a' y1 y
XML::LibXML::Element=SCALAR(0x8e8e130) at 1.pl line 6.
[root@localhost libxml]#
============================
III) INFO ACCORDING rt.cpan.org:
a) Distribution name and version:
XML-LibXML-1.65 (as well XML-LibXML-1.64)
libxml2-2.6.30-1
b) Perl version
This is perl, v5.8.8 built for i386-linux-thread-multi
c) Operating System vendor and version
cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)