line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Tree::Simple::SAX::Handler; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
21183
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
65
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
55
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
269
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
2022
|
use Tree::Simple; |
|
2
|
|
|
|
|
5686
|
|
|
2
|
|
|
|
|
12
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
50
|
use base 'XML::SAX::Base'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
2977
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
3
|
|
|
3
|
1
|
2785
|
my ($_class, $root_tree) = @_; |
17
|
3
|
100
|
33
|
|
|
27
|
(blessed($root_tree) && $root_tree->isa('Tree::Simple')) |
|
|
|
50
|
|
|
|
|
18
|
|
|
|
|
|
|
|| die "The root tree must be a Tree::Simple tree" |
19
|
|
|
|
|
|
|
if defined($root_tree); |
20
|
3
|
|
33
|
|
|
20
|
my $class = ref($_class) || $_class; |
21
|
3
|
|
|
|
|
38
|
my $self = $class->SUPER::new(); |
22
|
3
|
|
66
|
|
|
322
|
$self->{_root_tree} = $root_tree || Tree::Simple->new(); |
23
|
3
|
|
|
|
|
93
|
$self->{_current_tree} = $self->{_root_tree}; |
24
|
3
|
|
|
|
|
10
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
1
|
431
|
sub getRootTree { (shift)->{_root_tree} } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub start_element { |
30
|
14
|
|
|
14
|
1
|
159942
|
my ($self, $el) = @_; |
31
|
14
|
|
|
|
|
70
|
my $new_tree = $self->{_root_tree}->new(); |
32
|
14
|
|
|
|
|
424
|
my $node_value = { tag_type => $el->{Name} }; |
33
|
14
|
|
|
|
|
24
|
my $attrs = $el->{Attributes}; |
34
|
14
|
|
|
|
|
15
|
$node_value->{$attrs->{$_}->{Name}} = $attrs->{$_}->{Value} foreach keys %{$attrs}; |
|
14
|
|
|
|
|
47
|
|
35
|
14
|
|
|
|
|
44
|
$new_tree->setNodeValue($node_value); |
36
|
14
|
|
|
|
|
93
|
$self->{_current_tree}->addChild($new_tree); |
37
|
14
|
|
|
|
|
1247
|
$self->{_current_tree} = $new_tree; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub end_element { |
41
|
14
|
|
|
14
|
1
|
1798
|
my ($self) = @_; |
42
|
14
|
|
|
|
|
38
|
$self->{_current_tree} = $self->{_current_tree}->getParent(); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub characters { |
46
|
18
|
|
|
18
|
1
|
1021
|
my ($self, $el) = @_; |
47
|
18
|
100
|
|
|
|
107
|
return if $el->{Data} =~ /^\s+$/; |
48
|
9
|
|
|
|
|
50
|
$self->{_current_tree}->addChild( |
49
|
|
|
|
|
|
|
$self->{_root_tree}->new({ |
50
|
|
|
|
|
|
|
tag_type => 'CDATA', |
51
|
|
|
|
|
|
|
content => $el->{Data} |
52
|
|
|
|
|
|
|
}) |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |