Skip Menu |
 

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

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

People
Owner: MANWAR [...] cpan.org
Requestors: charleswoerner [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.13
Fixed in: 1.20



Subject: setNodeText doesn't work with unabbreviated attribute axis syntax
Download (untitled) / with headers
text/plain 299b
setNodeText() doesn't work with the unabbreviated attribute axis syntax. For example, you can't say $xpath->setNodeText("/foo/bar/baz/attribute::id", "id1"); The abbreviated axis syntax "/foo/bar/baz/\@id='123'" does work, so there is a suitable workaround. Still, it appears to be a bug.
From: charleswoerner [...] gmail.com
Download (untitled) / with headers
text/plain 423b
Attached is a test case and a patch which address this issue. On Fri Apr 06 20:28:37 2007, cwoerner wrote: Show quoted text
> setNodeText() doesn't work with the unabbreviated attribute axis syntax. > For example, you can't say > > $xpath->setNodeText("/foo/bar/baz/attribute::id", "id1"); > > The abbreviated axis syntax "/foo/bar/baz/\@id='123'" does work, so > there is a suitable workaround. Still, it appears to be a bug.
package main; use strict; use warnings; use Test::More tests => 3; use_ok("XML::XPath"); my $path = XML::XPath->new(ioref => \*DATA); $path->createNode("/child::foo/child::bar/child::baz"); # # test unabbreviated syntax # $path->setNodeText("/child::foo/child::bar/child::baz/attribute::id", "id1"); my $set = $path->find("/foo/bar/baz"); my @nodelist = $set->get_nodelist; ok($nodelist[0]->toString =~ /id="id1"/); # # test abbreviated syntax # $path->setNodeText("/foo/bar/baz/\@id", "id2"); $set = $path->find("/foo/bar/baz"); @nodelist = $set->get_nodelist; ok($nodelist[0]->toString =~ /id="id2"/); __DATA__ <?xml version="1.0" ?> <instanceData> </instanceData>
From: charleswoerner [...] gmail.com
Download (untitled) / with headers
text/plain 515b
And here's the patch. On Fri Apr 06 20:33:55 2007, cwoerner wrote: Show quoted text
> Attached is a test case and a patch which address this issue. > > On Fri Apr 06 20:28:37 2007, cwoerner wrote:
> > setNodeText() doesn't work with the unabbreviated attribute axis syntax. > > For example, you can't say > > > > $xpath->setNodeText("/foo/bar/baz/attribute::id", "id1"); > > > > The abbreviated axis syntax "/foo/bar/baz/\@id='123'" does work, so > > there is a suitable workaround. Still, it appears to be a bug.
>
--- /usr/local/lib/perl5/site_perl/5.8.6/XML/XPath.pm 2003-01-26 11:33:17.000000000 -0800 +++ lib/XML/XPath.pm 2007-04-06 15:34:12.000000000 -0700 @@ -190,7 +190,7 @@ return undef if (!defined $nodeset); # could not find node my @nodes = $nodeset->get_nodelist; if ($#nodes < 0) { - if ($node_path =~ m|/@([^/]+)$|) { + if ($node_path =~ m{/(?:@|attribute::)([^/]+)$}) { # attribute not found, so try to create it my $parent_path = $`; my $attr = $1;
Download (untitled) / with headers
text/plain 125b
Hi, Thanks for reporting the issue and the patch as well. I will try to get it applied asap. 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.