line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Filter::SimpleXML; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
124912
|
use 5.024; |
|
2
|
|
|
|
|
12
|
|
4
|
2
|
|
|
2
|
|
10
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
14
|
|
5
|
2
|
|
|
2
|
|
1118
|
use strictures 2; |
|
2
|
|
|
|
|
3355
|
|
|
2
|
|
|
|
|
90
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
1733
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
5595
|
|
|
2
|
|
|
|
|
29
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
2917
|
use Moose qw(has extends); |
|
2
|
|
|
|
|
1025184
|
|
|
2
|
|
|
|
|
18
|
|
12
|
2
|
|
|
2
|
|
14545
|
use MooseX::NonMoose; |
|
2
|
|
|
|
|
2282
|
|
|
2
|
|
|
|
|
8
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
extends 'Moose::Object', 'POE::Filter'; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
155714
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
202
|
|
17
|
2
|
|
|
2
|
|
1716
|
use XML::LibXML; |
|
2
|
|
|
|
|
128746
|
|
|
2
|
|
|
|
|
17
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'buffer' => ( |
22
|
|
|
|
|
|
|
'is' => 'ro', |
23
|
|
|
|
|
|
|
'traits' => ['Array'], |
24
|
|
|
|
|
|
|
'isa' => 'ArrayRef', |
25
|
|
|
|
|
|
|
'lazy' => 1, |
26
|
|
|
|
|
|
|
'clearer' => '_clear_buffer', |
27
|
|
|
|
|
|
|
'default' => sub { [] }, |
28
|
|
|
|
|
|
|
'handles' => { |
29
|
|
|
|
|
|
|
'has_buffer' => 'count', |
30
|
|
|
|
|
|
|
'all_buffer' => 'elements', |
31
|
|
|
|
|
|
|
'push_buffer' => 'push', |
32
|
|
|
|
|
|
|
'shift_buffer' => 'shift', |
33
|
|
|
|
|
|
|
'unshift_buffer' => 'unshift', |
34
|
|
|
|
|
|
|
'join_buffer' => 'join', |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has 'callback' => ( |
39
|
|
|
|
|
|
|
'is' => 'ro', |
40
|
|
|
|
|
|
|
'isa' => 'CodeRef', |
41
|
|
|
|
|
|
|
'lazy' => 1, |
42
|
|
|
|
|
|
|
'default' => sub { |
43
|
|
|
|
|
|
|
sub { Carp::confess('Parsing error happened: ' . join "\n", @_); }; |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'parser' => ( |
48
|
|
|
|
|
|
|
'is' => 'ro', |
49
|
|
|
|
|
|
|
'isa' => 'XML::LibXML', |
50
|
|
|
|
|
|
|
'lazy' => 1, |
51
|
|
|
|
|
|
|
'builder' => '_build_parser', |
52
|
|
|
|
|
|
|
'clearer' => '_clear_parser', |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _build_parser { |
56
|
1
|
|
|
1
|
|
13
|
return XML::LibXML->new('no_blanks' => 1); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_one_start { |
60
|
3
|
|
|
3
|
1
|
9452
|
my ($self, $raw) = @_; |
61
|
|
|
|
|
|
|
|
62
|
3
|
100
|
|
|
|
15
|
if (defined $raw) { |
63
|
2
|
|
|
|
|
6
|
foreach my $raw_data (@{$raw}) { |
|
2
|
|
|
|
|
6
|
|
64
|
2
|
|
|
|
|
144
|
$self->push_buffer($raw_data); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
9
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_one { |
72
|
3
|
|
|
3
|
1
|
127
|
my ($self) = @_; |
73
|
|
|
|
|
|
|
|
74
|
3
|
|
|
|
|
8
|
my $buf = q{}; |
75
|
|
|
|
|
|
|
|
76
|
3
|
|
|
|
|
7
|
my $nodes = []; |
77
|
|
|
|
|
|
|
|
78
|
3
|
|
|
|
|
134
|
while ($self->has_buffer) { |
79
|
2
|
|
|
|
|
78
|
my $eppframe = $self->shift_buffer; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
eval { |
82
|
2
|
|
|
|
|
5
|
push @{$nodes}, $self->parser->load_xml('string' => $eppframe); |
|
2
|
|
|
|
|
66
|
|
83
|
1
|
|
|
|
|
565
|
1; |
84
|
2
|
100
|
|
|
|
5
|
} or do { |
85
|
1
|
|
50
|
|
|
803
|
my $err = $EVAL_ERROR || 'Zombie error'; |
86
|
1
|
|
|
|
|
157
|
$self->callback->($err); |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
11
|
return $nodes; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub put { |
94
|
2
|
|
|
2
|
1
|
5386
|
my ($self, $nodes) = @_; |
95
|
2
|
|
|
|
|
8
|
my $output = []; |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
5
|
foreach my $node (@{$nodes}) { |
|
2
|
|
|
|
|
7
|
|
98
|
1
|
|
|
|
|
3
|
push @{$output}, $node->toString; |
|
1
|
|
|
|
|
20
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
97
|
return $output; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
2
|
|
|
2
|
|
1350
|
no Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
23
|
|
105
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=pod |
110
|
|
|
|
|
|
|
=encoding utf8 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 NAME |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
POE::Filter::SimpleXML - Simple XML parsing for the POE framework |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 VERSION |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
version 1.140700 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SYNOPSIS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
use POE::Filter::SimpleXML; |
123
|
|
|
|
|
|
|
my $filter = POE::Filter::SimpleXML->new; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $wheel = POE::Wheel:ReadWrite->new( |
126
|
|
|
|
|
|
|
Filter => $filter, |
127
|
|
|
|
|
|
|
InputEvent => 'input_event', |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 DESCRIPTION |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
POE::Filter::SimpleXML provides POE with a XML parsing strategy for |
133
|
|
|
|
|
|
|
POE::Wheels that will be dealing with Complete XML documents. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The parser is XML::LibXML |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 PRIVATE_ATTRIBUTES |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 buffer |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
is: ro, isa: ArrayRef, traits: Array |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
buffer holds the raw data to be parsed, there should be one XML document per |
144
|
|
|
|
|
|
|
entry. Access to this attribute is provided by the following methods: |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
handles => |
147
|
|
|
|
|
|
|
{ |
148
|
|
|
|
|
|
|
has_buffer => 'count', |
149
|
|
|
|
|
|
|
all_buffer => 'elements', |
150
|
|
|
|
|
|
|
push_buffer => 'push', |
151
|
|
|
|
|
|
|
shift_buffer => 'shift', |
152
|
|
|
|
|
|
|
unshift_buffer => 'unshift', |
153
|
|
|
|
|
|
|
join_buffer => 'join', |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 callback |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
is: ro, isa: CodeRef |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
callback holds the CodeRef to be call in the event that there is an exception |
161
|
|
|
|
|
|
|
generated while parsing content. By default it holds a CodeRef that simply |
162
|
|
|
|
|
|
|
calls Carp::confess. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 parser |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
is: ro, isa: XML::LibXML |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
parser holds an instance of the XML::LibXML parser. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 PUBLIC_METHODS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 get_one_start |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
(ArrayRef $raw?) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This method is part of the POE::Filter API. See L<POE::Filter/get_one_start> |
177
|
|
|
|
|
|
|
for an explanation of its usage. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 get_one |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
returns (ArrayRef) |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This method is part of the POE::Filter API. See L<POE::Filter/get_one> for an |
184
|
|
|
|
|
|
|
explanation of its usage. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 put |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
(ArrayRef $nodes) returns (ArrayRef) |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This method is part of the POE::Filter API. See L<POE::Filter/put> for an |
191
|
|
|
|
|
|
|
explanation of its usage. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 PRIVATE_METHODS |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 AUTHOR |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Mathieu Arnold <mat@cpan.org> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Mathieu Arnold <mat@cpan.org> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
204
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
__END__ |
209
|
|
|
|
|
|
|
|