r18615 - in /trunk/libxml-xpathengine-perl: Changes META.yml debian/changelog lib/XML/XPathEngine.pm lib/XML/XPathEngine/Literal.pm lib/XML/XPathEngine/NodeSet.pm lib/XML/XPathEngine/Number.pm lib/XML/XPathEngine/Step.pm t/01_basic.t
gregoa-guest at users.alioth.debian.org
gregoa-guest at users.alioth.debian.org
Tue Apr 15 15:37:00 UTC 2008
Author: gregoa-guest
Date: Tue Apr 15 15:36:59 2008
New Revision: 18615
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=18615
Log:
New upstream release, closes two Debian bugs:
- stringification overload broken (closes: #460297)
- "and" in Xpath(Engine) should be commutative (closes: #460281)
Modified:
trunk/libxml-xpathengine-perl/Changes
trunk/libxml-xpathengine-perl/META.yml
trunk/libxml-xpathengine-perl/debian/changelog
trunk/libxml-xpathengine-perl/lib/XML/XPathEngine.pm
trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Literal.pm
trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/NodeSet.pm
trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Number.pm
trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Step.pm
trunk/libxml-xpathengine-perl/t/01_basic.t
Modified: trunk/libxml-xpathengine-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/Changes?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/Changes (original)
+++ trunk/libxml-xpathengine-perl/Changes Tue Apr 15 15:36:59 2008
@@ -1,4 +1,24 @@
Revision history for XML::XPathEngine
+
+version 0.10
+fix: overloading did not quite work (literals returned by findvalue
+ woult cause an exception when used as numbers).
+ the fix is to return a real string in findvalue, instead of
+ an XML::XPath::Engine::Literal object that then needs to be overloaded
+ while this theoretically could break code that would rely on
+ the return being an object, I doubt this is the case in Real Code.
+ let me know if this causes any problem
+ Bug found by Niko Tyni and reported on Debian
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=460297
+ reported on RT: http://rt.cpan.org/Public/Bug/Display.html?id=34908
+ bug tested in the XML::DOM::XPath 0.14 test suite
+
+fix: predicates using the position and/or other conditions would fail,
+ as the position would not be saved in Step.pm
+ Reported by Stephane Bortzmeyer, patched by Niko Tyni
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=460281
+ http://rt.cpan.org/Ticket/Display.html?id=34907
+ bug tested in the XML::DOM::XPath 0.14 test suite
version: 0.09
fix: namespace processing was a bit dodgy, it's been cleaned up now.
Modified: trunk/libxml-xpathengine-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/META.yml?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/META.yml (original)
+++ trunk/libxml-xpathengine-perl/META.yml Tue Apr 15 15:36:59 2008
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: XML-XPathEngine
-version: 0.09
+version: 0.10
abstract: a re-usable XPath engine for DOM-like trees
license: ~
author:
Modified: trunk/libxml-xpathengine-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/debian/changelog?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/debian/changelog (original)
+++ trunk/libxml-xpathengine-perl/debian/changelog Tue Apr 15 15:36:59 2008
@@ -1,3 +1,11 @@
+libxml-xpathengine-perl (0.10-1) UNRELEASED; urgency=low
+
+ * New upstream release, closes two Debian bugs:
+ - stringification overload broken (closes: #460297)
+ - "and" in Xpath(Engine) should be commutative (closes: #460281)
+
+ -- gregor herrmann <gregor+debian at comodo.priv.at> Tue, 15 Apr 2008 17:34:50 +0200
+
libxml-xpathengine-perl (0.09-1) unstable; urgency=low
* New upstream release.
Modified: trunk/libxml-xpathengine-perl/lib/XML/XPathEngine.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/lib/XML/XPathEngine.pm?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/lib/XML/XPathEngine.pm (original)
+++ trunk/libxml-xpathengine-perl/lib/XML/XPathEngine.pm Tue Apr 15 15:36:59 2008
@@ -5,7 +5,7 @@
use vars qw($VERSION $AUTOLOAD $revision);
-$VERSION = '0.09';
+$VERSION = '0.10';
$XML::XPathEngine::Namespaces = 0;
$XML::XPathEngine::DEBUG = 0;
@@ -106,7 +106,11 @@
if ($results->isa('XML::XPathEngine::NodeSet'))
{ return wantarray ? $results->get_nodelist : $results; }
else
- { return wantarray ? ($results) : $results; } # result should be SCALAR
+ { return wantarray ? XML::XPathEngine::NodeSet->new($results)
+ : $results;
+ } # result should be SCALAR
+ #{ return wantarray ? ($results) : $results; } # result should be SCALAR
+ #{ return wantarray ? () : XML::XPathEngine::NodeSet->new(); }
}
@@ -155,8 +159,10 @@
my $self = shift;
my ($path, $context) = @_;
my $results = $self->find( $path, $context);
- if ($results->isa('XML::XPathEngine::NodeSet')) { return $results->to_literal; }
- return $results;
+ if ($results->isa('XML::XPathEngine::NodeSet'))
+ { return $results->to_final_value; }
+ #{ return $results->to_literal; }
+ return $results->value;
}
sub exists
@@ -1045,13 +1051,8 @@
=head2 findvalue ($path, $context)
-Returns either a C<XML::XPathEngine::Literal>, a C<XML::XPathEngine::Boolean>
-or a C<XML::XPathEngine::Number> object. If the path returns a NodeSet,
-$nodeset->to_literal is called automatically for you (and thus a
-C<XML::XPathEngine::Literal> is returned). Note that
-for each of the objects stringification is overloaded, so you can just
-print the value found, or manipulate it in the ways you would a normal
-perl value (e.g. using regular expressions).
+Returns the result as a string (the concatenation of the values of the
+result nodes).
=head2 exists ($path, $context)
Modified: trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Literal.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Literal.pm?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Literal.pm (original)
+++ trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Literal.pm Tue Apr 15 15:36:59 2008
@@ -6,7 +6,7 @@
use strict;
use overload
- '""' => \&value,
+ '""' => \&value,
'cmp' => \&cmp;
sub new {
@@ -33,8 +33,14 @@
}
sub value {
- my $self = shift;
+ my $self = shift;
$$self;
+}
+
+sub value_as_number {
+ my $self = shift;
+ warn "numifying '", $$self, "' to '", +$$self, "'\n";
+ +$$self;
}
sub cmp {
Modified: trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/NodeSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/NodeSet.pm?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/NodeSet.pm (original)
+++ trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/NodeSet.pm Tue Apr 15 15:36:59 2008
@@ -118,6 +118,11 @@
return XML::XPathEngine::Number->new(
$self->to_literal
);
+}
+
+sub to_final_value{
+ my $self = CORE::shift;
+ return join('', map { $_->string_value } @$self);
}
1;
Modified: trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Number.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Number.pm?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Number.pm (original)
+++ trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Number.pm Tue Apr 15 15:36:59 2008
@@ -7,7 +7,6 @@
use overload
'""' => \&value,
- '0+' => \&value,
'<=>' => \&cmp;
sub new {
Modified: trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Step.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Step.pm?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Step.pm (original)
+++ trunk/libxml-xpathengine-perl/lib/XML/XPathEngine/Step.pm Tue Apr 15 15:36:59 2008
@@ -136,6 +136,8 @@
}
#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);
my $initial_nodeset = XML::XPathEngine::NodeSet->new();
@@ -154,7 +156,8 @@
# 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);
return $initial_nodeset;
}
Modified: trunk/libxml-xpathengine-perl/t/01_basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libxml-xpathengine-perl/t/01_basic.t?rev=18615&op=diff
==============================================================================
--- trunk/libxml-xpathengine-perl/t/01_basic.t (original)
+++ trunk/libxml-xpathengine-perl/t/01_basic.t Tue Apr 15 15:36:59 2008
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 15;
+use Test::More tests => 23;
use XML::XPathEngine;
BEGIN { push @INC, './t'; }
@@ -35,7 +35,7 @@
is( $xp->findvalue( '//kid1[@att1=~/v[345]/]', $tree), 'vkid3vkid5', "match on attributes");
-is( $xp->findvalue( '//@*', $tree), 'v1v1vvvxv2vvvxv3vvvxv4vvvxv5vvvx', 'match all attributes');
+is( $xp->findvalue( '//@*', $tree), 'v1v1vvvx1v2vvvx0v3vvvx1v4vvvx0v5vvvx1', 'match all attributes');
is( $xp->findvalue( '//@*[parent::*/@att1=~/v[345]/]', $tree), 'v3v4v5', 'match all attributes with a test');
is( $xp->findvalue( '//kid1[@att1="v3"]/following::gkid2[1]', $tree), 'gkid2 4', "following axis[1]");
@@ -44,7 +44,19 @@
is( $xp->findvalue( '//kid1[@att1="v3"]/preceding::gkid2[1]', $tree), 'gkid2 2', "preceding axis[1]");
is( $xp->findvalue( '//kid1[@att1="v3"]/preceding::gkid2[2]', $tree), 'gkid2 1', "preceding axis[1]");
is( $xp->findvalue( '//kid1[@att1="v3"]/preceding::gkid2', $tree), 'gkid2 1gkid2 2', "preceding axis");
-is( $xp->findvalue( 'count(//kid1)', $tree), '3', 'preceding count');
+
+is( $xp->findvalue( 'count(//kid1)', $tree), '3', 'count( //gkid1)');
+is( $xp->findvalue( 'count(//gkid2)', $tree), '5', 'count( //gkid2)');
+
+is( $xp->findvalue( 'count(/root[count(.//kid1)=count(.//gkid1)])', $tree), 1, 'count() in expression (count(//kid1)=count(//gkid1))');
+is( $xp->findvalue( 'count(/root[count(.//kid1)>count(.//gkid1)])', $tree), 0, 'count() in expression (returns 0)');
+is( $xp->findvalue( 'count(/root[count(.//kid1)=count(.//gkid2)])', $tree), 0, 'count() in expression (returns 1)');
+is( $xp->findvalue( 'count( root/*[count( ./gkid0) = 1])', $tree), 2, 'count() in expression (root/*[count( ./gkid0) = 1])');
+
+is( $xp->findvalue( 'count(//gkid2[@att2="vx" and @att3=1])', $tree), 3, 'count with and');
+is( $xp->findvalue( 'count(//gkid2[@att2="vx" and @att3])', $tree), 5, 'count with and');
+is( $xp->findvalue( 'count(//gkid2[@att2="vx" or @att3])', $tree), 5, 'count with or');
+
sub init_tree
{ my $tree = tree->new( 'att', name => 'tree', value => 'tree');
@@ -56,7 +68,7 @@
$kid->add_as_last_child_of( $root);
my $gkid1= tree->new( 'att', name => 'gkid' . $_ % 2, value => "gvkid$_", att2 => "vv");
$gkid1->add_as_last_child_of( $kid);
- my $gkid2= tree->new( 'att', name => 'gkid2', value => "gkid2 $_", att2 => "vx");
+ my $gkid2= tree->new( 'att', name => 'gkid2', value => "gkid2 $_", att2 => "vx", att3 => $_ % 2);
$gkid2->add_as_last_child_of( $kid);
}
More information about the Pkg-perl-cvs-commits
mailing list