line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::LibXML::SAX::ChunkParser; |
2
|
3
|
|
|
3
|
|
36663
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
127
|
|
3
|
3
|
|
|
3
|
|
19
|
use base qw(XML::SAX::Base); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
4797
|
|
4
|
3
|
|
|
3
|
|
73006
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Carp qw(croak); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.00008'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub DESTROY { |
10
|
|
|
|
|
|
|
my $self = shift; |
11
|
|
|
|
|
|
|
$self->clean_parser; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub clean_parser { |
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $option = delete $self->{ParserOptions}; |
18
|
|
|
|
|
|
|
if (! $option) { |
19
|
|
|
|
|
|
|
return; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
my $parser = delete $option->{LibParser}; |
22
|
|
|
|
|
|
|
if (! $parser) { |
23
|
|
|
|
|
|
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
# break a possible circular reference |
26
|
|
|
|
|
|
|
$parser->set_handler( undef ); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_parser { |
30
|
|
|
|
|
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
my $options = $self->{ParserOptions}; |
32
|
|
|
|
|
|
|
if (! $options) { |
33
|
|
|
|
|
|
|
$options = {}; |
34
|
|
|
|
|
|
|
$self->{ParserOptions} = $options; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $parser = $options->{LibParser}; |
38
|
|
|
|
|
|
|
if (! $parser) { |
39
|
|
|
|
|
|
|
$parser = $options->{LibParser} = XML::LibXML->new; |
40
|
|
|
|
|
|
|
$parser->set_handler($self); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
return $parser; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub parse_chunk { |
46
|
|
|
|
|
|
|
my ($self, $chunk) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $parser = $self->get_parser(); |
49
|
|
|
|
|
|
|
eval { |
50
|
|
|
|
|
|
|
$parser->parse_chunk( $chunk ); |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if ( $parser->{SAX}->{State} == 1 ) { |
54
|
|
|
|
|
|
|
croak( "SAX Exception not implemented, yet; Data ended before document ended\n" ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
if ( $@ ) { |
58
|
|
|
|
|
|
|
croak $@; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub finish { |
63
|
|
|
|
|
|
|
my $self = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $parser = $self->get_parser(); |
66
|
|
|
|
|
|
|
if ($parser) { |
67
|
|
|
|
|
|
|
$parser->parse_chunk("", 1); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$self->clean_parser(); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |