line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: LocationPath.pm,v 1.8 2001/03/16 11:10:08 matt Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package XML::XPathEngine::LocationPath; |
4
|
2
|
|
|
2
|
|
1112
|
use XML::XPathEngine::Root; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
50
|
|
5
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
718
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
63
|
|
|
63
|
0
|
90
|
my $class = shift; |
9
|
63
|
|
|
|
|
101
|
my $self = []; |
10
|
63
|
|
|
|
|
222
|
bless $self, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub as_string { |
14
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
15
|
0
|
|
|
|
|
0
|
my $string; |
16
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < @$self; $i++) { |
17
|
0
|
|
|
|
|
0
|
$string .= $self->[$i]->as_string; |
18
|
0
|
0
|
|
|
|
0
|
$string .= "/" if $self->[$i+1]; |
19
|
|
|
|
|
|
|
} |
20
|
0
|
|
|
|
|
0
|
return $string; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub as_xml { |
24
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
25
|
0
|
|
|
|
|
0
|
my $string = "\n"; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < @$self; $i++) { |
28
|
0
|
|
|
|
|
0
|
$string .= $self->[$i]->as_xml; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
$string .= "\n"; |
32
|
0
|
|
|
|
|
0
|
return $string; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub set_root { |
36
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
37
|
0
|
|
|
|
|
0
|
unshift @$self, XML::XPathEngine::Root->new(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub evaluate { |
41
|
182
|
|
|
182
|
0
|
214
|
my $self = shift; |
42
|
|
|
|
|
|
|
# context _MUST_ be a single node |
43
|
182
|
|
|
|
|
190
|
my $context = shift; |
44
|
182
|
50
|
|
|
|
368
|
die "No context" unless $context; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# I _think_ this is how it should work :) |
47
|
|
|
|
|
|
|
|
48
|
182
|
|
|
|
|
501
|
my $nodeset = XML::XPathEngine::NodeSet->new(); |
49
|
182
|
|
|
|
|
497
|
$nodeset->push($context); |
50
|
|
|
|
|
|
|
|
51
|
182
|
|
|
|
|
306
|
foreach my $step (@$self) { |
52
|
|
|
|
|
|
|
# For each step |
53
|
|
|
|
|
|
|
# evaluate the step with the nodeset |
54
|
316
|
|
|
|
|
423
|
my $pos = 1; |
55
|
316
|
|
|
|
|
803
|
$nodeset = $step->evaluate($nodeset); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
179
|
|
|
|
|
473
|
return $nodeset; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |