| 1 | package XML::SAX::SimpleDispatcher; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use base qw(XML::SAX::Base); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use constant CALLBACK => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use constant EXPR => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 13 | 2 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 14 | 2 | my %param = @_; | |||||||||||||||||||||||||||
| 15 | 2 | my $proc = $param{process}; | |||||||||||||||||||||||||||
| 16 | 2 | for my $key (keys %$proc) { | |||||||||||||||||||||||||||
| 17 | 1 | $self->{__proc}{$key} = $proc->{$key}; | |||||||||||||||||||||||||||
| 18 | 1 | $self->{__cb}{$key} = $proc->{$key}->[CALLBACK]; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | 2 | return $self; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | sub start_document { | ||||||||||||||||||||||||||
|
Subroutine
start_document: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 1 | $self->{__elements} = []; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 7 | ▶ | sub start_element { | ||||||||||||||||||||||||||
|
Subroutine
start_element: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | 7 | my ($data) = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 7 | my $elements = $self->{__elements}; | |||||||||||||||||||||||||||
| 33 | 7 | my $parent_path = '/' . join ('/', @$elements); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 7 | my $name = $data->{Name}; | |||||||||||||||||||||||||||
| 36 | my %attrs = | ||||||||||||||||||||||||||||
| 37 | 0 | map { $data->{Attributes}{$_}{Name} => $data->{Attributes}{$_}{Value} } | |||||||||||||||||||||||||||
| 38 | 7 | keys %{ $data->{Attributes} }; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 7 | ▶ | if ( $self->{__proc}{$parent_path} and ! $self->{__stash}{$parent_path}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"__proc"}{$parent_path} and not $self->{"__stash"}{$parent_path}
MC/DC50%1/2
$self->{"__proc"}{$parent_path} and not $self->{"__stash"}{$parent_path}
$self->{"__proc"}{$parent_path}
not $self->{"__stash"}{$parent_path}
Truth table66%2/3
A and not(B)
A= $self->{"__proc"}{$parent_path}B= not $self->{"__stash"}{$parent_path}
| |||||||||||||||||||||||||||||
| 41 | $self->{__stash}{$parent_path} = | ||||||||||||||||||||||||||||
| 42 | 3 | { map { $_ => undef } @{ $self->{__proc}{$parent_path}->[EXPR] } }; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 7 | push @$elements, $name; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 13 | ▶ | sub characters { | ||||||||||||||||||||||||||
|
Subroutine
characters: called CC=5 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||
| 49 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 50 | 13 | my ($data) = @_; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 13 | my $elements = $self->{__elements}; | |||||||||||||||||||||||||||
| 53 | 13 | ▶ | my $current = $elements->[-1] or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 13 | my $parent_path = '/' . join ('/', @$elements[0..$#$elements-1]); | |||||||||||||||||||||||||||
| 55 | 13 | my $chars = $data->{Data}; | |||||||||||||||||||||||||||
| 56 | 13 | ▶ | if ($self->{__stash}{$parent_path}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 3 | ▶ | if (my $val = $self->{__stash}{$parent_path}{$current}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (ref $val eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | push @{$self->{__stash}{$parent_path}{$current}}, $chars; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||
| 62 | 0 | $self->{__stash}{$parent_path}{$current} = [$val, $chars]; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||||||||||
| 66 | 3 | $self->{__stash}{$parent_path}{$current} = $chars; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 7 | ▶ | sub end_element { | ||||||||||||||||||||||||||
|
Subroutine
end_element: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 73 | 7 | my ($data) = @_; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 7 | my $elements = $self->{__elements}; | |||||||||||||||||||||||||||
| 76 | 7 | ▶ | my $current = $elements->[-1] or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 7 | my $path = '/' . join ('/', @$elements); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 7 | ▶ | if ($self->{__stash}{$path}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 3 | my $stash = delete $self->{__stash}{$path}; | |||||||||||||||||||||||||||
| 81 | 3 | my @ret = map {$stash->{$_}} @{$self->{__proc}{$path}->[EXPR]}; | |||||||||||||||||||||||||||
| 82 | 3 | $self->{__cb}{$path}->(@ret); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 7 | pop @$elements; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 3 | 1; | |||||||||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||||||||||