From 254af7b78bf9c8e6e207f6244fa55e4f2b0d50cd Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 18 Aug 2009 11:42:56 +0200 Subject: added documentation --- lib/PPIx/XPath.pm | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'lib/PPIx') diff --git a/lib/PPIx/XPath.pm b/lib/PPIx/XPath.pm index d4975e4..586236c 100644 --- a/lib/PPIx/XPath.pm +++ b/lib/PPIx/XPath.pm @@ -387,6 +387,86 @@ __END__ PPIx::XPath - an XPath implementation for the PDOM +=head1 SYNOPSIS + + use PPI; + use PPI::XPath; + use Tree::XPathEngine; + + my $pdom = PPI::Document->new('some_code.pl'); + my $xpath = Tree::XPathEngine->new(); + my @subs = $xpath->findnodes('//Statement-Sub',$pdom); + my @vars = $xpath->findnodes('//Token-Symbol',$pdom); + +Deprecated interface, backward-compatible with C version +1: + + use PPIx::XPath; + + my $pxp = PPIx::XPath->new("some_code.pl"); + my @subs = $pxp->match("//Statement::Sub"); + my $vars = $pxp->match("//Token::Symbol"); + +=head1 DESCRIPTION + +This module augments L's classes with the methods required by +L, allowing you to perform complex XPath matches +against any PDOM tree. + +See L for details about its methods. + +=head2 Mapping the PDOM to the XPath data model + +=over 4 + +=item * + +Each node in the PDOM is an element as seen by XPath + +=item * + +The name of the element is the class name of the node, minus the +initial C, with C<::> replaced by C<->. That is: + + ($xpath_name = substr($pdom_node->class,5)) =~ s/::/-/g; + +=item * + +Only "significant" nodes are seen by XPath + +=item * + +all scalar-valued accessors of PDOM nodes are visible as attributes + +=item * + +"here-docs" contents are I mapped + +=back + +=head1 BUGS and LIMITATIONS + +=over 4 + +=item * + +"here-docs" contents are I mapped + +=item * + +node ordering is slow, because I could not find a way in PPI to +compare two nodes for document order; suggestions are most welcome + +=back + +=head1 SEE ALSO + +L + +L + +L (the XPath specification) + =head1 AUTHOR Dan Brook original author -- cgit v1.2.3