summaryrefslogtreecommitdiff
path: root/lib/Tree/Transform/XSLTish/Optimizer.pod
blob: e721e723ddf11b808e0cd871d8cd0eaa56925f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
=head1 random notes
 
C</> is in fact C</child::> (so C</whatever::foo> does not count)
C<//> can also be C<descendants(-or-self)?> (check that option)
C<..> can also be C<parent>
 
use Tree::XPathEngine::_parse to get a properly parsed XPath
 
path starts with C</>, apply only from root
 
path contains C</> but no C<//>, apply only at C<count('/') - count('..')> upwards
 
path contains C</> but no C<..>, start at C<count('/') - count('..')> upwards (ok, C<//> counts as 1 C</>) and go up to root
 
what about C<ancestors(-or-self)?> ??
 
 
--------
 
an optimizer takes a match rule and adds three slots:
 
=over 4
 
=item C<opt_pattern>
 
a pattern to use instead of the C<match> one
 
=item C<expected_result>
 
enum, specifying what the pattern (either C<match> or C<opt_pattern>)
should return for this rule to be considered matching:
 
=over 8
 
=item C<this>
 
the node we are applying the rule to
 
=item C<any>
 
any node
 
=back
 
=item C<min_depth>
 
the minimum depth (on the C<ancestor-or-self::> axis) to test; 0 (or
C<undef>) means start at the current node, 1 means start at its
parent, and so on
 
=item C<max_depth>
 
the maximum depth (on the C<ancestor-or-self::> axis) to test;
C<undef> means "unlimited", i.e. stop only at the document root
 
=back
 
So:
 
C<< match => 'foo' >> or C<< match => '//foo' >> would produce C<<
opt_pattern => 'self::foo', min_depth => 0, max_depth => 0 >>
 
C<< match => 'foo/bar' >> or C<< match => '//foo/bar' >> would produce
C<< opt_pattern => 'self::bar/parent::foo', min_depth => 0, max_depth
=> 0 >>
 
---------
 
we need a proper structure matcher!