Skip Menu |

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

Report information
The Basics
Id: 44248
Status: resolved
Priority: 0/
Queue: Tree-DAG_Node-XPath

People
Owner: Nobody in particular
Requestors: DAKKAR [...] cpan.org
Cc:
AdminCc:

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



Subject: Tree::DAG_Node::XPath::Root lacks a few methods
the helper "Root" class should implement the whole interface for Tree::XPathEngine, so that we can invoke 'findnodes' etc on any node obtained by a Tree::DAG_Node::XPath.
Subject: Re: [rt.cpan.org #44248] Tree::DAG_Node::XPath::Root lacks a few methods
Date: Tue, 17 Mar 2009 18:28:48 +0100
To: bug-Tree-DAG_Node-XPath [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
DAKKAR via RT wrote: Show quoted text
> Tue Mar 17 13:03:44 2009: Request 44248 was acted upon. > Transaction: Ticket created by DAKKAR > Queue: Tree-DAG_Node-XPath > Subject: Tree::DAG_Node::XPath::Root lacks a few methods > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: DAKKAR@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=44248 > > > > the helper "Root" class should implement the whole interface for > Tree::XPathEngine, so that we can invoke 'findnodes' etc on any node > obtained by a Tree::DAG_Node::XPath.
Drats, I didn't know anybody was using this module! I'll get to it right away, sorry. Do you have a test case by any chance? -- mirod
On Tue Mar 17 13:28:56 2009, xmltwig@gmail.com wrote: Show quoted text
> Drats, I didn't know anybody was using this module!
I'm using it for tests of a module based on Tree::XPathEngine Show quoted text
> I'll get to it right away, sorry. Do you have a test case by any chance?
I have something better: a patch :)
diff --git a/lib/Tree/DAG_Node/XPath.pm b/lib/Tree/DAG_Node/XPath.pm index 44cc60c..b905f44 100644 --- a/lib/Tree/DAG_Node/XPath.pm +++ b/lib/Tree/DAG_Node/XPath.pm @@ -119,6 +119,12 @@ sub xpath_get_attributes { return (); } sub xpath_is_document_node { return 1 } sub xpath_is_element_node { return 0 } sub xpath_is_attribute_node { return 0 } +sub xpath_get_parent_node { return; } +sub xpath_get_root_node { return $_[0] } +sub xpath_get_name { return; } +sub xpath_get_next_sibling { return; } +sub xpath_get_previous_sibling { return; } + 1; diff --git a/t/Tree-DAG_Node-XPath.t b/t/Tree-DAG_Node-XPath.t index 4fa44b7..7106c77 100644 --- a/t/Tree-DAG_Node-XPath.t +++ b/t/Tree-DAG_Node-XPath.t @@ -5,7 +5,7 @@ ######################### use strict; -use Test::More tests => 115; +use Test::More tests => 121; BEGIN { use_ok('Tree::DAG_Node::XPath') }; ######################### @@ -116,7 +116,7 @@ ok( $root->xpath_is_element_node => "root is element node"); my @root_atts= $root->xpath_get_attributes; is( $root_atts[0]->xpath_get_value => 'root', "->xpath_get_attributes in list context"); my $root_atts= $root->xpath_get_attributes; -is( $root->xpath_get_attributes => 1, "->xpath_get_attributes in scalar context"); +is( $root_atts => 1, "->xpath_get_attributes in scalar context"); my $att= ($root->findnodes( '@id'))[0]; ok( $att->xpath_is_attribute_node => "att is attribute node"); @@ -125,6 +125,12 @@ ok( !$att->xpath_is_element_node => "att is not element node"); my $fake_root= $root->xpath_get_parent_node; ok( $fake_root->xpath_is_document_node => "fake root is not document node"); ok( !$fake_root->xpath_is_element_node => "fake root is not element node"); +ok( !$fake_root->xpath_get_parent_node => "fake root does not have a parent"); +is( $fake_root->xpath_get_root_node, $fake_root, "fake root is its own root"); +ok( !$fake_root->xpath_get_attributes => "fake root has no attributes"); +ok( !defined($fake_root->xpath_get_name) => "fake root does not have a name"); +ok( !defined($fake_root->xpath_get_next_sibling) => "fake root does not have a next sibling"); +ok( !defined($fake_root->xpath_get_previous_sibling) => "fake root does not have a prev sibling"); # testing methods to get nodes content is( $att->xpath_get_value => 'root', "root id attribute with ->xpath_get_value");
The patch has been applied in version 0.10. Thank you.