1Pod::Abstract::Path(3)User Contributed Perl DocumentationPod::Abstract::Path(3)
2
3
4

NAME

6       Pod::Abstract::Path - Search for POD nodes matching a path within a
7       document tree.
8

SYNOPSIS

10        /head1(1)/head2          # All head2 elements under
11                                 # the 2nd head1 element
12        //item                   # All items anywhere
13        //item[@label =~ {^\*$}] # All items with '*' labels.
14        //head2[/hilight]        # All head2 elements containing
15                                 # "hilight" elements
16
17        # Top level head1s containing head2s that have headings matching
18        # "NAME", and also have at least one list somewhere in their
19        # contents.
20        /head1[/head2[@heading =~ {NAME}]][//over]
21
22        # Top level headings having the same title as the following heading.
23        /head1[@heading = >>@heading]
24
25        # Top level headings containing at least one subheading with the same
26        # name.
27        /head1[@heading = ./head2@heading]
28

DESCRIPTION

30       Pod::Abstract::Path is a path selection syntax that allows fast and
31       easy traversal of Pod::Abstract documents. While it has a simple
32       syntax, there is significant complexity in the queries that you can
33       create.
34
35       Not all of the designed features have yet been implemented, but it is
36       currently quite useful, and all of the filters in "paf" make use of Pod
37       Paths.
38
39   SYMBOLS:
40       /   Selects children of the left hand side.
41
42       //  Selects all descendants of the left hand side.
43
44       .   Selects the current node - this is a NOP that can be used in
45           expressions.
46
47       ..  Selects the parrent node. If there are multiple nodes selected, all
48           of their parents will be included.
49
50       ^   Selects the root node of the tree for the current node. This allows
51           you to escape from a nested expression. Note that this is the ROOT
52           node, not the node that you started from.
53
54           If you want to evaluate an expression from a node as though it were
55           the root node, the easiest ways are to detach or dup it - otherwise
56           the root operator will find the original root node.
57
58       name, #cut, :text, :verbatim, :paragraph
59           Any element name, or symbolic type name, will restrict the
60           selection to only elements matching that type. e.g,
61           ""//:paragraph"" will select all descendants, anywhere, but then
62           restrict that set to only ":paragraph" type nodes.
63
64           Names together separated by spaces will match all of those names -
65           e.g: "//head1 over" will match all lists and all head1s.
66
67       &, | (union and intersection)
68           Union will take expressions on either side, and return all nodes
69           that are members of either set. Intersection returns nodes that are
70           members of BOTH sets. These can be used to extend expressions, and
71           within [ expressions ] where a path is supported (left side of a
72           match, left or right side of an = sign). These are NOT logical
73           and/or, though a similar effect can be induced through these
74           operators.
75
76       @attrname
77           The named attribute of the nodes on the left hand side. Current
78           attributes are @heading for head1 through head4, and @label for
79           list items.
80
81       [ expression ]
82           Select only the left hand elements that match the expression in the
83           brackets. The expression will be evaluated from the point of view
84           of each node in the current result set.
85
86           Expressions can be:
87
88           simple: "[/head2]"
89               Any regular path will be true if there are any nodes matched.
90               The above example will be true if there are any head2 nodes as
91               direct children of the selected node.
92
93           regex match: "[@heading =~ {FOO}]"
94               A regex match will be true if the left hand expression has
95               nodes that match the regular expression between the braces on
96               the right hand side. The above example will match anything with
97               a heading containing "FOO".
98
99               Optionally, the right hand closing brace may have the "i"
100               modifier to cause case-insensitive matching. i.e "[@heading =~
101               {foo}i]" will match "foo" or "fOO".
102
103           complement: "[! /head2 ]"
104               Reverses the remainder of the expression. The above example
105               will match anything without a child head2 node.
106
107           equality: "[ /node1 = /node2 ]"
108               Matches nodes that have at least one equality match. The right
109               hand expression can be a constant string (single quoted:
110               'string', or a second expression. If two expressions are used,
111               they are matched combinationally - i.e, all result nodes on the
112               left are matched against all result nodes on the right. Both
113               sides may contain nested expressions.
114

PERFORMANCE

116       Pod::Abstract::Path is not designed to be fast. It is designed to be
117       expressive and useful, but it involves sucessive
118       expand/de-duplicate/linear search operations and doing this with large
119       documents containing many nodes is not suitable for high performance
120       systems.
121
122       Simple expressions can be fast enough, but there is nothing to stop you
123       from writing "//[<condition>]" and linear-searching all 10,000 nodes of
124       your Pod document. Use with caution in interactive systems.
125

INTERFACE

127       It is recommended you use the "<Pod::Abstract::Node-"select>> method to
128       evaluate Path expressions.
129
130       If you wish to generate paths for use in other modules, use
131       "parse_path" to generate a parse tree, pass that as an argument to
132       "new", then use "process" to evaluate the expression against a list of
133       nodes. You can re-use the same parse tree to process multiple lists of
134       nodes in this fashion.
135

METHODS

137   filter_unique
138       It is possible during processing - especially using ^ or .. operators -
139       to generate many duplicate matches of the same nodes. Each pass around
140       the loop, we filter to unique nodes so that duplicates cannot inflate
141       more than one time.
142
143       This effectively means that "//^" (however awful that is) will match
144       one node only - just really inefficiently.
145
146   parse_path
147       Parse a list of lexemes and generate a driver tree for the process
148       method. This is a simple recursive descent parser with one element of
149       lookahead.
150

AUTHOR

152       Ben Lilburne <bnej@mac.com>
153
155       Copyright (C) 2009 Ben Lilburne
156
157       This program is free software; you can redistribute it and/or modify it
158       under the same terms as Perl itself.
159
160
161
162perl v5.12.0                      2009-05-26            Pod::Abstract::Path(3)
Impressum