line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# This is free software, you may use it and distribute it under the same terms as |
4
|
|
|
|
|
|
|
# Perl itself. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package XML::LibXML::SAX; |
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
2292
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
90
|
|
13
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
91
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
16
|
use vars qw($VERSION @ISA); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
184
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = "2.0209"; # VERSION TEMPLATE: DO NOT CHANGE |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
28
|
use XML::LibXML; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
38
|
|
20
|
3
|
|
|
3
|
|
1893
|
use XML::SAX::Base; |
|
3
|
|
|
|
|
37920
|
|
|
3
|
|
|
|
|
131
|
|
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
533
|
use parent qw(XML::SAX::Base); |
|
3
|
|
|
|
|
330
|
|
|
3
|
|
|
|
|
23
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
193
|
use Carp; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
183
|
|
25
|
3
|
|
|
3
|
|
1008
|
use IO::File; |
|
3
|
|
|
|
|
4015
|
|
|
3
|
|
|
|
|
2376
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub CLONE_SKIP { |
28
|
0
|
0
|
|
0
|
|
0
|
return $XML::LibXML::__threads_shared ? 0 : 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub set_feature { |
32
|
8
|
|
|
8
|
1
|
6493
|
my ($self, $feat, $val) = @_; |
33
|
|
|
|
|
|
|
|
34
|
8
|
50
|
|
|
|
28
|
if ($feat eq 'http://xmlns.perl.org/sax/join-character-data') { |
35
|
0
|
|
|
|
|
0
|
$self->{JOIN_CHARACTERS} = $val; |
36
|
0
|
|
|
|
|
0
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
17
|
shift(@_); |
40
|
8
|
|
|
|
|
32
|
return $self->SUPER::set_feature(@_); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _parse_characterstream { |
44
|
0
|
|
|
0
|
|
0
|
my ( $self, $fh ) = @_; |
45
|
|
|
|
|
|
|
# this my catch the xml decl, so the parser won't get confused about |
46
|
|
|
|
|
|
|
# a possibly wrong encoding. |
47
|
0
|
|
|
|
|
0
|
croak( "not implemented yet" ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# See: |
51
|
|
|
|
|
|
|
# https://rt.cpan.org/Public/Bug/Display.html?id=132759 |
52
|
|
|
|
|
|
|
sub _calc_new_XML_LibXML_parser_for_compatibility_with_XML_Simple_etc |
53
|
|
|
|
|
|
|
{ |
54
|
8
|
|
|
8
|
|
37
|
return XML::LibXML->new( expand_entities => 1, ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _parse_bytestream { |
58
|
0
|
|
|
0
|
|
0
|
my ( $self, $fh ) = @_; |
59
|
0
|
0
|
|
|
|
0
|
$self->{ParserOptions}{LibParser} = $self->_calc_new_XML_LibXML_parser_for_compatibility_with_XML_Simple_etc() unless defined $self->{ParserOptions}{LibParser}; |
60
|
0
|
|
|
|
|
0
|
$self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_fh; |
61
|
0
|
|
|
|
|
0
|
$self->{ParserOptions}{ParseFuncParam} = $fh; |
62
|
0
|
|
|
|
|
0
|
$self->_parse; |
63
|
0
|
|
|
|
|
0
|
return $self->end_document({}); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _parse_string { |
67
|
37
|
|
|
37
|
|
10542
|
my ( $self, $string ) = @_; |
68
|
37
|
100
|
|
|
|
126
|
$self->{ParserOptions}{LibParser} = $self->_calc_new_XML_LibXML_parser_for_compatibility_with_XML_Simple_etc() unless defined $self->{ParserOptions}{LibParser}; |
69
|
37
|
|
|
|
|
88
|
$self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_string; |
70
|
37
|
|
|
|
|
66
|
$self->{ParserOptions}{ParseFuncParam} = $string; |
71
|
37
|
|
|
|
|
93
|
$self->_parse; |
72
|
34
|
|
|
|
|
107
|
return $self->end_document({}); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _parse_systemid { |
76
|
1
|
|
|
1
|
|
443
|
my $self = shift; |
77
|
1
|
50
|
|
|
|
5
|
$self->{ParserOptions}{LibParser} = $self->_calc_new_XML_LibXML_parser_for_compatibility_with_XML_Simple_etc() unless defined $self->{ParserOptions}{LibParser}; |
78
|
1
|
|
|
|
|
6
|
$self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_file; |
79
|
1
|
|
|
|
|
3
|
$self->{ParserOptions}{ParseFuncParam} = shift; |
80
|
1
|
|
|
|
|
3
|
$self->_parse; |
81
|
1
|
|
|
|
|
8
|
return $self->end_document({}); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub parse_chunk { |
85
|
2
|
|
|
2
|
0
|
19
|
my ( $self, $chunk ) = @_; |
86
|
2
|
100
|
|
|
|
8
|
$self->{ParserOptions}{LibParser} = $self->_calc_new_XML_LibXML_parser_for_compatibility_with_XML_Simple_etc() unless defined $self->{ParserOptions}{LibParser}; |
87
|
2
|
|
|
|
|
10
|
$self->{ParserOptions}{ParseFunc} = \&XML::LibXML::parse_xml_chunk; |
88
|
2
|
|
|
|
|
6
|
$self->{ParserOptions}{LibParser}->{IS_FILTER}=1; # a hack to prevent parse_xml_chunk from issuing end_document |
89
|
2
|
|
|
|
|
5
|
$self->{ParserOptions}{ParseFuncParam} = $chunk; |
90
|
2
|
|
|
|
|
6
|
$self->_parse; |
91
|
2
|
|
|
|
|
5
|
return; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _parse { |
95
|
40
|
|
|
40
|
|
53
|
my $self = shift; |
96
|
40
|
|
|
|
|
95
|
my $args = bless $self->{ParserOptions}, ref($self); |
97
|
|
|
|
|
|
|
|
98
|
40
|
50
|
|
|
|
82
|
if (defined($self->{JOIN_CHARACTERS})) { |
99
|
0
|
|
|
|
|
0
|
$args->{LibParser}->{JOIN_CHARACTERS} = $self->{JOIN_CHARACTERS}; |
100
|
|
|
|
|
|
|
} else { |
101
|
40
|
|
|
|
|
73
|
$args->{LibParser}->{JOIN_CHARACTERS} = 0; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
40
|
|
|
|
|
132
|
$args->{LibParser}->set_handler( $self ); |
105
|
40
|
|
|
|
|
71
|
eval { |
106
|
40
|
|
|
|
|
116
|
$args->{ParseFunc}->($args->{LibParser}, $args->{ParseFuncParam}); |
107
|
|
|
|
|
|
|
}; |
108
|
|
|
|
|
|
|
|
109
|
40
|
50
|
|
|
|
188
|
if ( $args->{LibParser}->{SAX}->{State} == 1 ) { |
110
|
0
|
|
|
|
|
0
|
croak( "SAX Exception not implemented, yet; Data ended before document ended\n" ); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# break a possible circular reference |
114
|
40
|
|
|
|
|
127
|
$args->{LibParser}->set_handler( undef ); |
115
|
40
|
100
|
|
|
|
79
|
if ( $@ ) { |
116
|
3
|
|
|
|
|
133
|
croak $@; |
117
|
|
|
|
|
|
|
} |
118
|
37
|
|
|
|
|
54
|
return; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
|