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.06 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.06'; |
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
7
|
|
32656
|
use 5.006; |
|
7
|
|
|
|
|
19
|
|
16
|
7
|
|
|
7
|
|
27
|
use strict; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
142
|
|
17
|
7
|
|
|
7
|
|
23
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
176
|
|
18
|
7
|
|
|
7
|
|
4259
|
use Data::Dumper; |
|
7
|
|
|
|
|
71080
|
|
|
7
|
|
|
|
|
578
|
|
19
|
|
|
|
|
|
|
|
20
|
7
|
|
|
7
|
|
60
|
use vars qw(@EXPORT); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
421
|
|
21
|
7
|
|
|
7
|
|
3440
|
use XML::SAX; |
|
7
|
|
|
|
|
39977
|
|
|
7
|
|
|
|
|
360
|
|
22
|
7
|
|
|
7
|
|
4257
|
use XML::Handler::Trees; |
|
7
|
|
|
|
|
22293
|
|
|
7
|
|
|
|
|
224
|
|
23
|
7
|
|
|
7
|
|
46
|
use base 'XML::Simple'; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
6045
|
|
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
|
19
|
|
|
19
|
1
|
8017065
|
my $self; |
42
|
|
|
|
|
|
|
|
43
|
19
|
100
|
66
|
|
|
302
|
if ($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) { |
44
|
1
|
|
|
|
|
2
|
$self = shift; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
18
|
|
|
|
|
150
|
$self = XML::SAX::Simple->new(); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
19
|
|
|
|
|
1132
|
$self->SUPER::XMLin(@_); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub XMLout { |
54
|
1
|
|
|
1
|
1
|
42
|
my $self; |
55
|
|
|
|
|
|
|
|
56
|
1
|
50
|
33
|
|
|
13
|
if ($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) { |
57
|
0
|
|
|
|
|
0
|
$self = shift; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
1
|
|
|
|
|
13
|
$self = XML::SAX::Simple->new(); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
70
|
$self->SUPER::XMLout(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub build_tree { |
67
|
14
|
|
|
14
|
0
|
2796
|
my ($self, $filename, $string) = @_; |
68
|
|
|
|
|
|
|
|
69
|
14
|
|
|
|
|
33
|
$self->{nocollapse} = 1; |
70
|
|
|
|
|
|
|
|
71
|
14
|
50
|
66
|
|
|
93
|
if ($filename and $filename eq '-') { |
72
|
0
|
|
|
|
|
0
|
local($/); |
73
|
0
|
|
|
|
|
0
|
$string = ; |
74
|
0
|
|
|
|
|
0
|
$filename = undef; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
14
|
|
|
|
|
125
|
my $handler = XML::Handler::Tree->new(); |
78
|
14
|
|
|
|
|
166
|
my $parser = XML::SAX::ParserFactory->parser(Handler => $handler); |
79
|
|
|
|
|
|
|
|
80
|
14
|
|
|
|
|
373676
|
my $tree; |
81
|
|
|
|
|
|
|
|
82
|
14
|
100
|
|
|
|
44
|
if ($filename) { |
83
|
11
|
|
|
|
|
77
|
$tree = $parser->parse_uri($filename); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
else { |
86
|
3
|
50
|
33
|
|
|
32
|
if (ref($string) && ref($string) ne 'SCALAR') { |
87
|
0
|
|
|
|
|
0
|
$tree = $parser->parse_file($string); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
else { |
90
|
3
|
|
|
|
|
54
|
$tree = $parser->parse_string($string); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
11
|
|
|
|
|
43409
|
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 |