line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: XPath.pm,v 1.3 2003/11/10 08:30:33 grantm Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package File::Find::Rule::XPath; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
58665
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
124
|
|
7
|
1
|
|
|
1
|
|
965
|
use File::Find::Rule; |
|
1
|
|
|
|
|
9264
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
50
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
9
|
1
|
|
|
1
|
|
4
|
use Cwd (); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
21
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
493
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.03'; |
14
|
|
|
|
|
|
|
@ISA = qw(File::Find::Rule); |
15
|
|
|
|
|
|
|
@EXPORT = @File::Find::Rule::EXPORT; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub File::Find::Rule::xpath { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift()->_force_object; |
20
|
0
|
0
|
|
|
|
|
my $xpath = @_ ? shift : '/'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Use XML::LibXML if it's installed otherwise try XML::XPath |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $use_libxml = 0; |
26
|
0
|
0
|
|
|
|
|
if(eval { require XML::LibXML }) { |
|
0
|
0
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$use_libxml = 1; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
elsif(!eval { require XML::XPath }) { |
30
|
0
|
|
|
|
|
|
croak 'Can\'t locate XML::LibXML or XML::XPath in @INC'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $cwd = Cwd::cwd(); |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if($use_libxml) { |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->exec( |
38
|
|
|
|
|
|
|
sub { |
39
|
0
|
|
|
0
|
|
|
my($shortname, $path, $fullname) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
eval { |
42
|
0
|
0
|
|
|
|
|
unless(File::Spec->file_name_is_absolute($fullname)) { |
43
|
0
|
|
|
|
|
|
$fullname = File::Spec->rel2abs($fullname, $cwd); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $xp = XML::LibXML->new(); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$xp->parse_file($fullname)->find($xpath)->get_nodelist(); |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$self->exec( |
57
|
|
|
|
|
|
|
sub { |
58
|
0
|
|
|
0
|
|
|
my($shortname, $path, $fullname) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
eval { |
61
|
0
|
0
|
|
|
|
|
unless(File::Spec->file_name_is_absolute($fullname)) { |
62
|
0
|
|
|
|
|
|
$fullname = File::Spec->rel2abs($fullname, $cwd); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $xp = XML::XPath->new(filename => $fullname); |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$xp->exists($xpath); |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |