line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XSLT::Dependencies; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
66600
|
use vars qw ($VERSION); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
141
|
|
4
|
|
|
|
|
|
|
$VERSION = '0.2'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
7
|
2
|
|
|
2
|
|
7787
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use File::Spec; |
9
|
|
|
|
|
|
|
use Cwd qw(realpath); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $this = { |
15
|
|
|
|
|
|
|
start => undef, |
16
|
|
|
|
|
|
|
inc => {}, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
bless $this, $class; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return $this; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub explore { |
24
|
|
|
|
|
|
|
my ($this, $filename) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$this->{start} = realpath($filename); |
27
|
|
|
|
|
|
|
$this->{inc} = {}; |
28
|
|
|
|
|
|
|
$this->dep_list($this->{start}); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return grep {$_ ne $this->{start}} keys %{$this->{inc}}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub dep_list { |
34
|
|
|
|
|
|
|
my ($this, $filepath) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return [] if defined $this->{inc}{$filepath}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$this->{inc}{$filepath} = 1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my ($volume, $directory, $file) = File::Spec->splitpath($filepath); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $parser = new XML::LibXML; |
43
|
|
|
|
|
|
|
my $doc = $parser->parse_file($filepath); |
44
|
|
|
|
|
|
|
my $root = $doc->documentElement(); |
45
|
|
|
|
|
|
|
my @dependencies = $root->findnodes('//xsl:include | //xsl:import'); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my @deps; |
48
|
|
|
|
|
|
|
for my $dependency (@dependencies) { |
49
|
|
|
|
|
|
|
my $relative_href = $dependency->find('string(@href)')->value(); |
50
|
|
|
|
|
|
|
my $absolute_path = realpath(File::Spec->catfile($directory, $relative_href)); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
push @deps, $this->dep_list($absolute_path); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return \@deps; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |