line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::SAX::Simple; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
XML::SAX::Simple - SAX version of XML::Simple. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Version 0.07 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.07'; |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
25066
|
use 5.006; |
|
7
|
|
|
|
|
15
|
|
16
|
7
|
|
|
7
|
|
21
|
use strict; |
|
7
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
118
|
|
17
|
7
|
|
|
7
|
|
20
|
use warnings; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
148
|
|
18
|
7
|
|
|
7
|
|
3826
|
use Data::Dumper; |
|
7
|
|
|
|
|
42848
|
|
|
7
|
|
|
|
|
344
|
|
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
7
|
|
31
|
use vars qw(@EXPORT); |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
254
|
|
21
|
7
|
|
|
7
|
|
2791
|
use XML::SAX; |
|
7
|
|
|
|
|
24929
|
|
|
7
|
|
|
|
|
244
|
|
22
|
7
|
|
|
7
|
|
3277
|
use XML::Handler::Trees; |
|
7
|
|
|
|
|
17941
|
|
|
7
|
|
|
|
|
171
|
|
23
|
7
|
|
|
7
|
|
32
|
use base 'XML::Simple'; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
5122
|
|
24
|
|
|
|
|
|
|
@EXPORT = qw(XMLin XMLout); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
C is a very simple version of L but for SAX.It can |
29
|
|
|
|
|
|
|
be used as a complete drop-in replacement for L. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
See the documentation for L for details. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use XML::SAX::Simple qw(XMLin XMLout); |
36
|
|
|
|
|
|
|
my $hash = XMLin("foo.xml"); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub XMLin { |
41
|
100
|
|
|
100
|
1
|
10069138
|
my $self; |
42
|
|
|
|
|
|
|
|
43
|
100
|
100
|
100
|
|
|
1309
|
if ($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) { |
44
|
5
|
|
|
|
|
6
|
$self = shift; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
95
|
|
|
|
|
368
|
$self = XML::SAX::Simple->new(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
100
|
|
|
|
|
3515
|
$self->SUPER::XMLin(@_); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub XMLout { |
54
|
49
|
|
|
49
|
1
|
105921
|
my $self; |
55
|
|
|
|
|
|
|
|
56
|
49
|
100
|
66
|
|
|
310
|
if ($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) { |
57
|
2
|
|
|
|
|
3
|
$self = shift; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
47
|
|
|
|
|
185
|
$self = XML::SAX::Simple->new(); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
49
|
|
|
|
|
1750
|
$self->SUPER::XMLout(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub build_tree { |
67
|
92
|
|
|
92
|
0
|
9130
|
my ($self, $filename, $string) = @_; |
68
|
|
|
|
|
|
|
|
69
|
92
|
|
|
|
|
113
|
$self->{nocollapse} = 1; |
70
|
|
|
|
|
|
|
|
71
|
92
|
50
|
66
|
|
|
235
|
if ($filename and $filename eq '-') { |
72
|
0
|
|
|
|
|
0
|
local($/); |
73
|
0
|
|
|
|
|
0
|
$string = ; |
74
|
0
|
|
|
|
|
0
|
$filename = undef; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
92
|
|
|
|
|
379
|
my $handler = XML::Handler::Tree->new(); |
78
|
92
|
|
|
|
|
600
|
my $parser = XML::SAX::ParserFactory->parser(Handler => $handler); |
79
|
|
|
|
|
|
|
|
80
|
92
|
|
|
|
|
314661
|
my $tree; |
81
|
|
|
|
|
|
|
|
82
|
92
|
100
|
|
|
|
170
|
if ($filename) { |
83
|
15
|
|
|
|
|
65
|
$tree = $parser->parse_uri($filename); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else { |
86
|
77
|
100
|
66
|
|
|
316
|
if (ref($string) && ref($string) ne 'SCALAR') { |
87
|
1
|
|
|
|
|
6
|
$tree = $parser->parse_file($string); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
76
|
|
|
|
|
186
|
$tree = $parser->parse_string($$string); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
92
|
|
|
|
|
1218742
|
return $tree; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Matt Sergeant, matt@sergeant.org |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 REPOSITORY |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Currently maintained by Mohammad S Anwar (MANWAR), C<< >> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SEE ALSO |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L, L. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is free software. You may use it and distribute it under the same terms as |
114
|
|
|
|
|
|
|
Perl itself. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright (C) 2001 Matt Sergeant, matt@sergeant.org |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; # end of XML::SAX::Simple |