Subject: | namespace::* doesn't find all namespaces in scope |
Distribution: XML-XPath-1.13
Perl version: perl, v5.8.0 built for ppc-linux-thread-multi
Linux mynode 2.4.22-2f #1 Sun Nov 9 16:49:49 EST 2003 ppc ppc ppc GNU/Linux
When the following code is run the only namespace that is listed is ns4 "uri:namespace4"
The XPath namespace::* should return all namespaces that are in scope. The ns4 namespace is declared in the element at /AAA/DDD/BBB. However, the namespaces ns1 and ns3 are in scope and should also be returned by namespace::*. Note that ns2 is not in scope and should not be returned.
The expected behavior is as described in section 5.4 of the XPath 1.0 recommendation at
http://www.w3.org/TR/xpath#namespace-nodes
Code to illustrate the problem
use XML::XPath;
my $xp = XML::XPath->new( ioref => *DATA);
my @nodes = $xp->findnodes('/AAA/DDD/BBB');
foreach $node (@nodes) {
print $node->getName . "\n";
my @nsps = $xp->findnodes('namespace::*', $node);
foreach $nsp (@nsps) {
print "\tnamespace: " .$nsp->getPrefix . " is " . $nsp->getExpanded . "\n";
}
}
__DATA__
<AAA xmlns:ns1="uri:namespace1">
<BBB/>
<CCC xmlns:ns2="uri:namespace2"/>
<BBB/>
<CCC/>
<BBB/>
<!-- comment -->
<DDD xmlns:ns3="uri:namespace3">
<BBB xmlns:ns4="uri:namespace4"/>
Text
<BBB/>
</DDD>
<CCC/>
</AAA>