line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package XML::SAX::Expat::Incremental; |
4
|
2
|
|
|
2
|
|
1845
|
use base qw/XML::SAX::Expat/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1181
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
119
|
|
7
|
|
|
|
|
|
|
#use warnings; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
20
|
use vars qw/$VERSION/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
120
|
|
10
|
|
|
|
|
|
|
$VERSION = "0.05"; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
1233
|
use XML::Parser (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Carp qw/croak/; |
14
|
|
|
|
|
|
|
use Scalar::Util qw/weaken/; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub parse { |
17
|
|
|
|
|
|
|
my $p = shift; |
18
|
|
|
|
|
|
|
my $opts = $p->get_options(@_); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if ($p->{Parent}){ |
21
|
|
|
|
|
|
|
return $p->{Parent}->parse($opts); |
22
|
|
|
|
|
|
|
} else { |
23
|
|
|
|
|
|
|
if (defined $opts->{Source}{String}){ |
24
|
|
|
|
|
|
|
return $p->_parse_string($opts->{Source}{String}); |
25
|
|
|
|
|
|
|
} else { |
26
|
|
|
|
|
|
|
croak "The only thing I know how to parse is a string. You have to fetch the data for me yourself."; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub parse_more { |
32
|
|
|
|
|
|
|
my $p = shift; |
33
|
|
|
|
|
|
|
$p->parse_string(@_); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _parse_string { |
37
|
|
|
|
|
|
|
my $p = shift; |
38
|
|
|
|
|
|
|
my $xml = shift; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$p->parse_start unless $p->{_parsing}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$p->_expat_obj->parse_more($xml); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub parse_start { |
46
|
|
|
|
|
|
|
my $p = shift; |
47
|
|
|
|
|
|
|
my $opt = shift; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
croak "Can't parse_start - Already started" |
50
|
|
|
|
|
|
|
if $p->{_parsing}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$p->{_parsing} = 1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$p->_really_create_parser($opt); |
55
|
|
|
|
|
|
|
$p->_expat_obj($p->_parser_obj->parse_start); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub parse_done { |
59
|
|
|
|
|
|
|
my $p = shift; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
croak "Can't parse_done - Havn't started parsing. Call parse_start or just parse first." |
62
|
|
|
|
|
|
|
unless $p->{_parsing}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
undef $p->{_parsing}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
$p->_expat_obj->parse_done; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _really_create_parser { # we only create the parser when parse_start is called |
72
|
|
|
|
|
|
|
my $p = shift; |
73
|
|
|
|
|
|
|
my $opt = shift; |
74
|
|
|
|
|
|
|
$p->{_xml_parser_obj} ||= $p->SUPER::_create_parser($opt); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _create_parser { # this is defined by XML::SAX::Expat |
78
|
|
|
|
|
|
|
my $p = shift; |
79
|
|
|
|
|
|
|
$p->_expat_obj; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _expat_obj { |
83
|
|
|
|
|
|
|
my $p = shift; |
84
|
|
|
|
|
|
|
$p->{_expat_nb_obj} = shift if @_; |
85
|
|
|
|
|
|
|
weaken($p->{_expat_nb_obj}); |
86
|
|
|
|
|
|
|
$p->{_expat_nb_obj}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _parser_obj { |
90
|
|
|
|
|
|
|
my $p = shift; |
91
|
|
|
|
|
|
|
$p->{_xml_parser_obj} = shift if @_; |
92
|
|
|
|
|
|
|
weaken($p->{_xml_parser_obj}{__XSE}); # FIXME should go away |
93
|
|
|
|
|
|
|
$p->{_xml_parser_obj}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__PACKAGE__ |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |