Skip Menu |

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

Report information
The Basics
Id: 34854
Status: resolved
Priority: 0/
Queue: XML-XPathEngine

People
Owner: Nobody in particular
Requestors: mattn.jp [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.08
Fixed in: (no value)



Subject: XML::XPathEngine can't return value of 'count'
It seems that XML::XPathEngine does not return 'count' value as following. XML: <kid id="a1" /> <kid id="a2" /> <kid id="a3" /> XPath: findnodes('count(//kid[@id="a1" or @id="a2"])') # eq 2 I wrote a patch for fixing this problem. Please check and include. Regards, Thanks.
Subject: fix-to-return-count-value.diff
Index: t/01_basic.t =================================================================== --- t/01_basic.t (revision 9313) +++ t/01_basic.t (working copy) @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 15; use XML::XPathEngine; BEGIN { push @INC, './t'; } @@ -44,6 +44,7 @@ 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'); sub init_tree { my $tree = tree->new( 'att', name => 'tree', value => 'tree'); Index: lib/XML/XPathEngine.pm =================================================================== --- lib/XML/XPathEngine.pm (revision 9313) +++ lib/XML/XPathEngine.pm (working copy) @@ -106,7 +106,7 @@ if ($results->isa('XML::XPathEngine::NodeSet')) { return wantarray ? $results->get_nodelist : $results; } else - { return wantarray ? () : XML::XPathEngine::NodeSet->new(); } + { return wantarray ? ($results) : $results; } # result should be SCALAR }
From: MIROD [...] cpan.org
On Fri Apr 11 02:46:18 2008, mattn wrote: Show quoted text
> It seems that XML::XPathEngine does not return 'count' value as following. > > XML: > <kid id="a1" /> > <kid id="a2" /> > <kid id="a3" /> > > XPath: > findnodes('count(//kid[@id="a1" or @id="a2"])') # eq 2 > > I wrote a patch for fixing this problem. > Please check and include.
Nice catch, Patch applied and XML::XPathEngine 0.09 uploaded to CPAN. Of course after having done so, I thought that the right value to return might be an XML::XPathEngine::Number object. I have to try writing a test that would not pass the current code, using the result of the count might do the trick. I'll let you know. Thanks for the very thorough patch. __ mirod
From: mattn.jp [...] gmail.com
On 金曜日 4月 11 04:53:08 2008, MIROD wrote: Show quoted text
> On Fri Apr 11 02:46:18 2008, mattn wrote:
> > It seems that XML::XPathEngine does not return 'count' value as
following. Show quoted text
> > > > XML: > > <kid id="a1" /> > > <kid id="a2" /> > > <kid id="a3" /> > > > > XPath: > > findnodes('count(//kid[@id="a1" or @id="a2"])') # eq 2 > > > > I wrote a patch for fixing this problem. > > Please check and include.
> > Nice catch, > > Patch applied and XML::XPathEngine 0.09 uploaded to CPAN. > Of course after having done so, I thought that the right value to return > might be an XML::XPathEngine::Number object. I have to try writing a > test that would not pass the current code, using the result of the count > might do the trick. I'll let you know. > > Thanks for the very thorough patch. > > __ > mirod
ok, it seems good to me. thanks.