Skip Menu |
 

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

Report information
The Basics
Id: 32012
Status: resolved
Priority: 0/
Queue: XML-XPath

People
Owner: MANWAR [...] cpan.org
Requestors: ntyni [...] iki.fi
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.13
Fixed in: 1.27



Subject: XML::XPath::Step::evaluate() loses context info
Download (untitled) / with headers
text/plain 484b
Hi, this issue was apparently already forwarded to you in 2003, but I'm resubmitting it in the bug tracker. As reported in Debian bug #187583, http://bugs.debian.org/187583 , the 'position()=last()' condition is not working after other conditions. This happens because context information is lost in XML::XPath::Step::evaluate(). I'm attaching a testcase for this problem and a proposed fix. Please consider including it. Cheers, -- Niko Tyni (Debian Perl Group) ntyni@debian.org
Subject: 187583.patch
Download 187583.patch
text/x-diff 1.6k
diff --git a/XPath/Step.pm b/XPath/Step.pm index cff64a3..639fb4c 100644 --- a/XPath/Step.pm +++ b/XPath/Step.pm @@ -130,6 +130,8 @@ sub evaluate { my $from = shift; # context nodeset # warn "Step::evaluate called with ", $from->size, " length nodeset\n"; + my $saved_context = $self->{pp}->get_context_set; + my $saved_pos = $self->{pp}->get_context_pos; $self->{pp}->set_context_set($from); @@ -149,7 +151,8 @@ sub evaluate { # warn "Step::evaluate initial nodeset size: ", $initial_nodeset->size, "\n"; - $self->{pp}->set_context_set(undef); + $self->{pp}->set_context_set($saved_context); + $self->{pp}->set_context_pos($saved_pos); $initial_nodeset->sort; diff --git a/t/32context.t b/t/32context.t new file mode 100644 index 0000000..9f7d5e9 --- /dev/null +++ b/t/32context.t @@ -0,0 +1,27 @@ +use Test; +BEGIN { plan tests => 4 } + +use XML::XPath; +ok(1); + +my $xp = XML::XPath->new(ioref => *DATA); +ok($xp); + +# Debian bug #187583, http://bugs.debian.org/187583 +# Check that evaluation doesn't lose the context information + +my $nodes = $xp->find("text/para/node()[position()=last() and preceding-sibling::important]"); +ok("$nodes", " has a preceding sibling."); + +$nodes = $xp->find("text/para/node()[preceding-sibling::important and position()=last()]"); +ok("$nodes", " has a preceding sibling."); + +__DATA__ +<text> + <para>I start the text here, I break +the line and I go on, I <blink>twinkle</blink> and then I go on + again. +This is not a new paragraph.</para><para>This is a + <important>new</important> paragraph and + <blink>this word</blink> has a preceding sibling.</para> +</text>
Download (untitled) / with headers
text/plain 153b
Hi, Thanks for reporting the issue. I will very soon get it patched. Thanks for the providing the patch and test script. Best Regards, Mohammad S Anwar
Resolved.


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.