line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::Breaker::Parser::xml; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
384163
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
10
|
|
4
|
1
|
|
|
1
|
|
253
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
1
|
|
|
1
|
|
899
|
use Catmandu::Breaker; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
6
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
7
|
1
|
|
|
1
|
|
9
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.141'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has tags => (is => 'ro' , default => sub { +{} }); |
12
|
|
|
|
|
|
|
has breaker => (is => 'lazy'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _build_breaker { |
15
|
0
|
|
|
0
|
|
|
Catmandu::Breaker->new; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub add { |
19
|
0
|
|
|
0
|
0
|
|
my ($self, $data, $io) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
0
|
|
|
|
my $identifier = $data->{_id} // $self->breaker->counter; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$self->xpath_gen($data,[],sub { |
24
|
0
|
|
|
0
|
|
|
my ($tag,$value) = @_; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->tags->{$tag} = 1; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$io->print( |
29
|
|
|
|
|
|
|
$self->breaker->to_breaker( |
30
|
|
|
|
|
|
|
$identifier , |
31
|
|
|
|
|
|
|
$tag , |
32
|
|
|
|
|
|
|
$value) |
33
|
|
|
|
|
|
|
); |
34
|
0
|
|
|
|
|
|
}); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub xpath_gen { |
40
|
0
|
|
|
0
|
0
|
|
my ($self,$data,$path,$callback) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if (ref($data) eq 'HASH') { |
|
|
0
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
for my $key (keys %$data) { |
44
|
0
|
|
|
|
|
|
my $value = $data->{$key}; |
45
|
0
|
0
|
|
|
|
|
if (ref($value)) { |
46
|
0
|
|
|
|
|
|
$self->xpath_gen($value,[@$path,$key],$callback); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
|
|
|
|
|
$callback->(join("/",@$path,$key),$value); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif (ref($data) eq 'ARRAY') { |
55
|
0
|
|
|
|
|
|
for my $value (@$data) { |
56
|
0
|
0
|
|
|
|
|
if (ref($value)) { |
57
|
0
|
|
|
|
|
|
$self->xpath_gen($value,$path,$callback); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
0
|
|
|
|
|
|
$callback->(join("/",@$path),$value); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Catmandu::Exporter::Breaker::Parser::xml - handler for XML format |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This L<Catmandu::Breaker> handler breaks XML format. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L<Catmandu::XML> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |