| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
4
|
|
|
4
|
|
211159
|
use 5.006; # our |
|
|
4
|
|
|
|
|
15
|
|
|
2
|
4
|
|
|
4
|
|
19
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
103
|
|
|
3
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
281
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package IO::Async::XMLStream::SAXReader; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.001002'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Dispatch SAX events from an XML stream. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
|
12
|
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
1461
|
use parent 'IO::Async::Stream'; |
|
|
4
|
|
|
|
|
824
|
|
|
|
4
|
|
|
|
|
22
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
4
|
|
|
4
|
|
178484
|
use XML::LibXML::SAX::ChunkParser 0.00007; # Buggy Finish |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use IO::Async::XMLStream::SAXReader::DuckHandler; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
## no critic (NamingConventions) |
|
71
|
|
|
|
|
|
|
sub _SAXReader { |
|
72
|
|
|
|
|
|
|
my ($self) = @_; |
|
73
|
|
|
|
|
|
|
my $key = 'SAXReader'; |
|
74
|
|
|
|
|
|
|
return $self->{$key} if exists $self->{$key}; |
|
75
|
|
|
|
|
|
|
$self->{$key} = {}; |
|
76
|
|
|
|
|
|
|
$self->{$key}->{Parser} = XML::LibXML::SAX::ChunkParser->new( Handler => $self->{sax_handler} ); |
|
77
|
|
|
|
|
|
|
return $self->{$key}; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
## use critic |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my @XML_METHODS = qw( |
|
82
|
|
|
|
|
|
|
attlist_decl |
|
83
|
|
|
|
|
|
|
attribute_decl |
|
84
|
|
|
|
|
|
|
characters |
|
85
|
|
|
|
|
|
|
comment |
|
86
|
|
|
|
|
|
|
doctype_decl |
|
87
|
|
|
|
|
|
|
element_decl |
|
88
|
|
|
|
|
|
|
end_cdata |
|
89
|
|
|
|
|
|
|
end_document |
|
90
|
|
|
|
|
|
|
end_dtd |
|
91
|
|
|
|
|
|
|
end_element |
|
92
|
|
|
|
|
|
|
end_entity |
|
93
|
|
|
|
|
|
|
end_prefix_mapping |
|
94
|
|
|
|
|
|
|
entity_decl |
|
95
|
|
|
|
|
|
|
entity_reference |
|
96
|
|
|
|
|
|
|
error |
|
97
|
|
|
|
|
|
|
external_entity_decl |
|
98
|
|
|
|
|
|
|
fatal_error |
|
99
|
|
|
|
|
|
|
ignorable_whitespace |
|
100
|
|
|
|
|
|
|
internal_entity_decl |
|
101
|
|
|
|
|
|
|
notation_decl |
|
102
|
|
|
|
|
|
|
processing_instruction |
|
103
|
|
|
|
|
|
|
resolve_entity |
|
104
|
|
|
|
|
|
|
set_document_locator |
|
105
|
|
|
|
|
|
|
skipped_entity |
|
106
|
|
|
|
|
|
|
start_cdata |
|
107
|
|
|
|
|
|
|
start_document |
|
108
|
|
|
|
|
|
|
start_dtd |
|
109
|
|
|
|
|
|
|
start_element |
|
110
|
|
|
|
|
|
|
start_entity |
|
111
|
|
|
|
|
|
|
start_prefix_mapping |
|
112
|
|
|
|
|
|
|
unparsed_entity_decl |
|
113
|
|
|
|
|
|
|
warning |
|
114
|
|
|
|
|
|
|
xml_decl |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub configure { |
|
118
|
|
|
|
|
|
|
my ( $self, %params ) = @_; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
for my $method ('sax_handler') { |
|
121
|
|
|
|
|
|
|
next unless exists $params{$method}; |
|
122
|
|
|
|
|
|
|
$self->{$method} = delete $params{$method}; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
if ( not $self->{'sax_handler'} ) { |
|
126
|
|
|
|
|
|
|
$self->{'sax_handler'} = IO::Async::XMLStream::SAXReader::DuckHandler->new( { SAXReader => $self, }, ); |
|
127
|
|
|
|
|
|
|
for my $method (@XML_METHODS) { |
|
128
|
|
|
|
|
|
|
next unless exists $params{ 'on_' . $method }; |
|
129
|
|
|
|
|
|
|
$self->{ 'on_' . $method } = delete $params{ 'on_' . $method }; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
$self->_SAXReader; |
|
133
|
|
|
|
|
|
|
return $self->SUPER::configure(%params); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub on_read { |
|
137
|
|
|
|
|
|
|
my ( $self, $buffref, $eof ) = @_; |
|
138
|
|
|
|
|
|
|
my $text = substr ${$buffref}, 0, length ${$buffref}, q[]; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
$self->_SAXReader->{Parser}->parse_chunk($text) if length $text; |
|
141
|
|
|
|
|
|
|
if ($eof) { |
|
142
|
|
|
|
|
|
|
$self->_SAXReader->{Parser}->finish; |
|
143
|
|
|
|
|
|
|
return 0; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
return 1; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |