line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/LocationPath.pm 22 2006-02-13T14:00:25.731780Z mrodrigu $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Tree::XPathEngine::LocationPath; |
4
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
2050
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
155
|
|
|
155
|
1
|
251
|
my $class = shift; |
8
|
155
|
|
|
|
|
261
|
my $self = []; |
9
|
155
|
|
|
|
|
609
|
bless $self, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub as_string { |
13
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
14
|
0
|
|
|
|
|
0
|
my $string; |
15
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < @$self; $i++) { |
16
|
0
|
|
|
|
|
0
|
$string .= $self->[$i]->as_string; |
17
|
0
|
0
|
|
|
|
0
|
$string .= "/" if $self->[$i+1]; |
18
|
|
|
|
|
|
|
} |
19
|
0
|
|
|
|
|
0
|
return $string; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub as_xml { |
23
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
24
|
0
|
|
|
|
|
0
|
my $string = "\n"; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < @$self; $i++) { |
27
|
0
|
|
|
|
|
0
|
$string .= $self->[$i]->as_xml; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
$string .= "\n"; |
31
|
0
|
|
|
|
|
0
|
return $string; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub evaluate { |
36
|
640
|
|
|
640
|
1
|
769
|
my $self = shift; |
37
|
|
|
|
|
|
|
# context _MUST_ be a single node |
38
|
640
|
|
|
|
|
671
|
my $context = shift; |
39
|
640
|
50
|
|
|
|
1554
|
die "No context" unless $context; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# I _think_ this is how it should work :) |
42
|
|
|
|
|
|
|
|
43
|
640
|
|
|
|
|
2153
|
my $nodeset = Tree::XPathEngine::NodeSet->new(); |
44
|
640
|
|
|
|
|
1881
|
$nodeset->push($context); |
45
|
|
|
|
|
|
|
|
46
|
640
|
|
|
|
|
1163
|
foreach my $step (@$self) { |
47
|
|
|
|
|
|
|
# For each step |
48
|
|
|
|
|
|
|
# evaluate the step with the nodeset |
49
|
904
|
|
|
|
|
1221
|
my $pos = 1; |
50
|
904
|
|
|
|
|
2694
|
$nodeset = $step->evaluate($nodeset); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
638
|
|
|
|
|
2320
|
return $nodeset->remove_duplicates; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |