| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XML::Parser::Lite::Tree::XPath::Eval; |
|
2
|
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
170
|
use XML::Parser::Lite::Tree::XPath::Token; |
|
|
29
|
|
|
|
|
57
|
|
|
|
29
|
|
|
|
|
804
|
|
|
4
|
29
|
|
|
29
|
|
155
|
use Data::Dumper; |
|
|
29
|
|
|
|
|
63
|
|
|
|
29
|
|
|
|
|
1847
|
|
|
5
|
29
|
|
|
29
|
|
3095
|
use strict; |
|
|
29
|
|
|
|
|
58
|
|
|
|
29
|
|
|
|
|
29904
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
|
8
|
130
|
|
|
130
|
0
|
222
|
my ($class) = @_; |
|
9
|
130
|
|
|
|
|
566
|
my $self = bless {}, $class; |
|
10
|
130
|
|
|
|
|
563
|
$self->{error} = 0; |
|
11
|
130
|
|
|
|
|
1474
|
return $self; |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub query { |
|
15
|
130
|
|
|
130
|
0
|
314
|
my ($self, $xpath, $tree) = @_; |
|
16
|
130
|
|
|
|
|
226
|
$self->{error} = 0; |
|
17
|
130
|
|
|
|
|
256
|
$self->{tree} = $tree; |
|
18
|
|
|
|
|
|
|
|
|
19
|
130
|
|
|
|
|
1079
|
$self->{root} = XML::Parser::Lite::Tree::XPath::Result->new('nodeset', [$self->{tree}]); |
|
20
|
130
|
|
|
|
|
568
|
$self->{max_order} = $self->mark_orders($self->{tree}, 1, undef); |
|
21
|
|
|
|
|
|
|
|
|
22
|
130
|
|
|
|
|
310
|
$self->{uids} = {}; |
|
23
|
130
|
|
|
|
|
668
|
$self->mark_uids($self->{tree}); |
|
24
|
|
|
|
|
|
|
|
|
25
|
130
|
|
|
|
|
319
|
my $token = $xpath->{tokens}->[0]; |
|
26
|
130
|
50
|
|
|
|
333
|
unless (defined $token){ |
|
27
|
0
|
|
|
|
|
0
|
$self->{error} = "couldn't get root token to eval."; |
|
28
|
0
|
|
|
|
|
0
|
return 0; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
130
|
|
|
|
|
407
|
$self->mark_token($token); |
|
32
|
|
|
|
|
|
|
|
|
33
|
130
|
|
|
|
|
756
|
my $out = $token->eval($self->{root}); |
|
34
|
|
|
|
|
|
|
|
|
35
|
130
|
100
|
|
|
|
497
|
if ($out->is_error){ |
|
36
|
1
|
|
|
|
|
3
|
$self->{error} = $out->{value}; |
|
37
|
1
|
|
|
|
|
3
|
return 0; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
129
|
|
|
|
|
384
|
return $out; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
0
|
if ($out->{type} ne 'nodeset'){ |
|
43
|
0
|
|
|
|
|
0
|
$self->{error} = "Result was not a nodeset (was a $out->{type})"; |
|
44
|
0
|
|
|
|
|
0
|
return 0; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
return $out->{value}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub mark_orders { |
|
51
|
1185
|
|
|
1185
|
0
|
2231
|
my ($self, $tag, $i, $parent) = @_; |
|
52
|
|
|
|
|
|
|
|
|
53
|
1185
|
|
|
|
|
2227
|
$tag->{order} = $i++; |
|
54
|
1185
|
|
|
|
|
1851
|
$tag->{parent} = $parent; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1185
|
|
|
|
|
1428
|
for my $child(@{$tag->{children}}){ |
|
|
1185
|
|
|
|
|
3264
|
|
|
57
|
1055
|
|
|
|
|
2371
|
$i = $self->mark_orders($child, $i, $tag); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
1185
|
|
|
|
|
2771
|
return $i; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub mark_token { |
|
64
|
926
|
|
|
926
|
0
|
1045
|
my ($self, $token) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
926
|
|
|
|
|
1406
|
$token->{root} = $self->{root}; |
|
67
|
926
|
|
|
|
|
1787
|
$token->{max_order} = $self->{max_order}; |
|
68
|
|
|
|
|
|
|
|
|
69
|
926
|
|
|
|
|
935
|
for my $child(@{$token->{tokens}}){ |
|
|
926
|
|
|
|
|
2201
|
|
|
70
|
796
|
|
|
|
|
1588
|
$self->mark_token($child); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub mark_uids { |
|
75
|
1185
|
|
|
1185
|
0
|
1412
|
my ($self, $tag) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# |
|
78
|
|
|
|
|
|
|
# mark |
|
79
|
|
|
|
|
|
|
# |
|
80
|
|
|
|
|
|
|
|
|
81
|
1185
|
100
|
|
|
|
2882
|
if ($tag->{type} eq 'element'){ |
|
82
|
|
|
|
|
|
|
|
|
83
|
985
|
|
|
|
|
1459
|
$tag->{uid} = ''; |
|
84
|
|
|
|
|
|
|
|
|
85
|
985
|
|
|
|
|
2001
|
my $id = $tag->{attributes}->{id}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
985
|
100
|
66
|
|
|
3466
|
if (defined $id && length $id){ |
|
88
|
710
|
50
|
|
|
|
3366
|
unless (defined $self->{uids}->{$id}){ |
|
89
|
|
|
|
|
|
|
|
|
90
|
710
|
|
|
|
|
989
|
$tag->{uid} = $id; |
|
91
|
710
|
|
|
|
|
1774
|
$self->{uids}->{$id} = 1; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# |
|
98
|
|
|
|
|
|
|
# descend |
|
99
|
|
|
|
|
|
|
# |
|
100
|
|
|
|
|
|
|
|
|
101
|
1185
|
100
|
100
|
|
|
5531
|
if ($tag->{type} eq 'root' || $tag->{type} eq 'element'){ |
|
102
|
|
|
|
|
|
|
|
|
103
|
1115
|
|
|
|
|
1277
|
for my $child (@{$tag->{children}}){ |
|
|
1115
|
|
|
|
|
2877
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
1055
|
|
|
|
|
2143
|
$self->mark_uids($child); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |