line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::xml_transform; |
2
|
|
|
|
|
|
|
#ABSTRACT: transform XML using XSLT stylesheet |
3
|
|
|
|
|
|
|
our $VERSION = '0.14'; #VERSION |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
22922
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
140951
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
285
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
2109
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XML::LibXSLT; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Catmandu::XML::Transformer; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Base'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has field => (is => 'ro', required => 1); |
15
|
|
|
|
|
|
|
has file => (is => 'ro', required => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has _transformer => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
lazy => 1, |
20
|
|
|
|
|
|
|
default => sub { |
21
|
|
|
|
|
|
|
Catmandu::XML::Transformer->new( |
22
|
|
|
|
|
|
|
stylesheet => $_[0]->file |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
around BUILDARGS => sub { |
28
|
|
|
|
|
|
|
my($orig,$class,$field,%opts) = @_; |
29
|
|
|
|
|
|
|
$orig->($class,field => $field, file => $opts{file}); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub emit { |
33
|
|
|
|
|
|
|
my ($self,$fixer) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $path = $fixer->split_path($self->field()); |
36
|
|
|
|
|
|
|
my $key = pop @$path; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $transformer = $fixer->capture($self->_transformer); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $fixer->emit_walk_path($fixer->var,$path,sub{ |
41
|
|
|
|
|
|
|
my $var = $_[0]; |
42
|
|
|
|
|
|
|
$fixer->emit_get_key($var,$key,sub{ |
43
|
|
|
|
|
|
|
my $var = $_[0]; |
44
|
|
|
|
|
|
|
return "${var} = ${transformer}->transform(${var});"; |
45
|
|
|
|
|
|
|
}); |
46
|
|
|
|
|
|
|
}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |