|/||Selects children of the left hand side.|
|//||Selects all descendants of the left hand side.|
|.||Selects the current node - this is a NOP that can be used in expressions.|
|..||Selects the parrent node. If there are multiple nodes selected, all of their parents will be included.|
Selects the root node of the tree for the current node. This allows
you to escape from a nested expression. Note that this is the ROOT
node, not the node that you started from.
If you want to evaluate an expression from a node as though it were the root node, the easiest ways are to detach or dup it - otherwise the root operator will find the original root node.
|name, #cut, :text, :verbatim, :paragraph||
Any element name, or symbolic type name, will restrict the selection
to only elements matching that type. e.g, "//:paragraph" will
select all descendants, anywhere, but then restrict that set to only
:paragraph type nodes.
Names together separated by spaces will match all of those names - e.g: //head1 over will match all lists and all head1s.
|&, | (union and intersection)||Union will take expressions on either side, and return all nodes that are members of either set. Intersection returns nodes that are members of BOTH sets. These can be used to extend expressions, and within [ expressions ] where a path is supported (left side of a match, left or right side of an = sign). These are NOT logical and/or, though a similar effect can be induced through these operators.|
|@attrname||The named attribute of the nodes on the left hand side. Current attributes are @heading for head1 through head4, and @label for list items.|
|[ expression ]||
Select only the left hand elements that match the expression in the
brackets. The expression will be evaluated from the point of view of
each node in the current result set.
Expressions can be:
Pod::Abstract::Path is not designed to be fast. It is designed to be expressive and useful, but it involves sucessive expand/de-duplicate/linear search operations and doing this with large documents containing many nodes is not suitable for high performance systems.
Simple expressions can be fast enough, but there is nothing to stop you from writing //[<condition>] and linear-searching all 10,000 nodes of your Pod document. Use with caution in interactive systems.
It is recommended you use the <Pod::Abstract::Node-select>> method to evaluate Path expressions.
If you wish to generate paths for use in other modules, use parse_path to generate a parse tree, pass that as an argument to new, then use process to evaluate the expression against a list of nodes. You can re-use the same parse tree to process multiple lists of nodes in this fashion.
It is possible during processing - especially using ^ or .. operators - to generate many duplicate matches of the same nodes. Each pass around the loop, we filter to unique nodes so that duplicates cannot inflate more than one time.
This effectively means that //^ (however awful that is) will match one node only - just really inefficiently.
Parse a list of lexemes and generate a driver tree for the process method. This is a simple recursive descent parser with one element of lookahead.
Ben Lilburne <firstname.lastname@example.org>
Copyright (C) 2009 Ben Lilburne
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||POD::ABSTRACT::PATH (3)||2010-01-03|