Skip Menu |

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

Report information
The Basics
Id: 28368
Status: rejected
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: woodworthjames [...] yahoo.com
Cc:
AdminCc:

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



Subject: passing in optional context node to "find"
Date: Wed, 18 Jul 2007 09:38:44 -0700 (PDT)
To: bug-XML-LibXML [...] rt.cpan.org
From: James Woodworth <woodworthjames [...] yahoo.com>
Hello, running perl5.8.7, with libxml-1.63. if i understand the docs, these should be the same: my $xpath3 = '/quotelist/quotation[last()]/source'; my @nodes3 = $doc->findnodes( $xpath3 ); my $result3 = $nodes3[0]->find( '../@id' ); print $result3->string_value, "\n"; and my $xpath4 = '/quotelist/quotation[last()]/source'; my @nodes4 = $doc->findnodes( $xpath4 ); my $result4 = $doc->find( '../@id', $nodes4[0] ); print $result4->string_value, "\n"; thanks. --------------------------------- Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.
I believe you somehow confuse the docs. On which page of the documentation did you see $doc->findnodes($xpath,$node)? I believe you confuse $doc with an XML::LibXML::XPathContext object. Feel free to reopen the bug if you think I'm wrong, but then point me directly to the place where this misleading information is supposed to be written. For now, I'm rejecting this bug. -- Petr On st 18.čec.2007 12:39:11, woodworthjames@yahoo.com wrote: Show quoted text
> Hello, > > running perl5.8.7, with libxml-1.63. > if i understand the docs, these should be the same: > > my $xpath3 = '/quotelist/quotation[last()]/source'; > my @nodes3 = $doc->findnodes( $xpath3 ); > my $result3 = $nodes3[0]->find( '../@id' ); > print $result3->string_value, "\n"; > > and > > my $xpath4 = '/quotelist/quotation[last()]/source'; > my @nodes4 = $doc->findnodes( $xpath4 ); > my $result4 = $doc->find( '../@id', $nodes4[0] ); > print $result4->string_value, "\n"; > > thanks. > > > --------------------------------- > Yahoo! oneSearch: Finally, mobile search that gives answers, not
web Show quoted text
> links.
Subject: Re: [rt.cpan.org #28368] passing in optional context node to "find"
Date: Wed, 18 Jul 2007 14:29:52 -0700 (PDT)
To: bug-XML-LibXML [...] rt.cpan.org
From: James Woodworth <woodworthjames [...] yahoo.com>
Hello Petr, you are right that i am looking at "XML::LibXML::XPathContext" page. However, the last sentence to the "find" methods state that "Optionally, a node may be passed to set the context node for the query". i believe i did pass in a node. i do not doubt for a second that i am using it correctly, but if that is the case, the doc seems misleading. Petr Pajas via RT <bug-XML-LibXML@rt.cpan.org> wrote: I believe you somehow confuse the docs. On which page of the documentation did you see $doc->findnodes($xpath,$node)? I believe you confuse $doc with an XML::LibXML::XPathContext object. Feel free to reopen the bug if you think I'm wrong, but then point me directly to the place where this misleading information is supposed to be written. For now, I'm rejecting this bug. -- Petr On st 18.čec.2007 12:39:11, woodworthjames@yahoo.com wrote: Show quoted text
> Hello, > > running perl5.8.7, with libxml-1.63. > if i understand the docs, these should be the same: > > my $xpath3 = '/quotelist/quotation[last()]/source'; > my @nodes3 = $doc->findnodes( $xpath3 ); > my $result3 = $nodes3[0]->find( '../@id' ); > print $result3->string_value, "\n"; > > and > > my $xpath4 = '/quotelist/quotation[last()]/source'; > my @nodes4 = $doc->findnodes( $xpath4 ); > my $result4 = $doc->find( '../@id', $nodes4[0] ); > print $result4->string_value, "\n"; > > thanks. > > > --------------------------------- > Yahoo! oneSearch: Finally, mobile search that gives answers, not
web Show quoted text
> links.
--------------------------------- Pinpoint customers who are looking for what you sell.
Exactly. XML::LibXML::XPathContext is one class, whose objects are created as $xpc = XML::LibXML::XPathContext->new; once done, you may apply a findnodes() method to $xpc, which DOES take a second argument - a context node, so you can do e.g. $xpc->findnodes($xpath, $node); (open a different bug if you think that objects from THIS CLASS complain about passing an optional 2nd argument to the findnodes method). But you are calling a entirely (though similarly named) method when you call $doc->findnodes($xpath,$node) since $doc, at least I presume (you didn't give much context), is NOT from the XML::LibXML::XPathContext class, but from the XML::LibXML::Document class, which is derived from XML::LibXML::Node. So you just have to see the documentation of XML::LibXML::Node for the method findnodes() when you apply it on $doc. What's not clear about that? You learn the methods of the class A from documentation of A, and the method of the class B from the documentation of B. Different classes can have similarly named methods that behave similarly or differently and take similar or different arguments. No one had ever complained about that - isn't that why classes were invented in the first place. Please contact me on a private email if you still think you have a point I just don't get, but I'm pretty sure this is an obvious mistake on your side and that the documentation need no fixing. Rejecting again! -- Petr