| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package XML::Saxtract; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | $XML::Saxtract::VERSION = '1.04'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Streaming parse XML data into a result hash based upon a specification hash | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # PODNAME: XML::Saxtract | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our @EXPORT_OK = qw(saxtract_string saxtract_url); | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use XML::SAX; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 12 | ▶ | sub saxtract_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saxtract_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 12 | my $xml_string = shift; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | my $spec = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | my %options = @_; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | my $handler = XML::Saxtract::ContentHandler->new( $spec, $options{object} ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | my $parser = XML::SAX::ParserFactory->parser( Handler => $handler ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | $parser->parse_string($xml_string); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | return $handler->get_result(); | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | sub saxtract_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
saxtract_url: called CC=4 SCAR=17.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my $spec = shift; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | my %options = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | my $agent = $options{agent} || LWP::UserAgent->new(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$options{'agent'} || 'LWP::UserAgent'->new
MC/DC0%0/2
$options{'agent'} || 'LWP::UserAgent'->new
$options{'agent'}
'LWP::UserAgent'->new
Truth table33%1/3
A || B
A= $options{'agent'}B= 'LWP::UserAgent'->new
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | my $response = $agent->get($uri); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if ( !$response->is_success() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ( $options{die_on_failure} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | die($response); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | return saxtract_string( $response->content(), $spec, %options ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | package XML::Saxtract::ContentHandler; | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | $XML::Saxtract::ContentHandler::VERSION = '1.04'; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | use parent qw(Class::Accessor); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | __PACKAGE__->mk_ro_accessors(qw(result)); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 12 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 12 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 12 | my $self = bless( {}, $class ); | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | return $self->_init(@args); | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 110 | ▶ | sub _add_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_value: called CC=13 SCAR=25.8
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 110 | my $object = shift; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 110 | my $spec = shift; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 110 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 110 | my $type = ref($spec); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 110 | ▶ | if ( !$type ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 86 | $object->{$spec} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | elsif ( $type eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $object->{$$spec} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | elsif ( $type eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | &$spec( $object, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 23 | my $name = $spec->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 23 | my $subspec_type = ref( $spec->{type} ); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 23 | ▶ | if ($subspec_type) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | ▶ | if ( $subspec_type eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 7 | my $subspec_object = $object->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 7 | ▶ | unless ($subspec_object) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | $subspec_object = {}; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | $object->{$name} = $subspec_object; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 7 | &{ $spec->{type} }( $subspec_object, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | elsif ( $spec->{type} eq 'array' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | if ( !defined( $object->{$name} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $object->{$name} = []; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | push( @{ $object->{$name} }, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | elsif ( $spec->{type} eq 'map' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | ▶ | if ( !defined( $object->{$name} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 3 | $object->{$name} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 9 | $object->{$name}{ $value->{ $spec->{key} } } = $value; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | elsif ( $spec->{type} eq 'first' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | ▶ | if ( !defined( $object->{$name} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | $object->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # type 'last' or default | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $object->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 54 | ▶ | sub characters { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
characters: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 54 | my ( $self, $characters ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 54 | ▶ | return if ( $self->{skip} > 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 54 | ▶ | if ( defined($characters) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 54 | push( @{ $self->{buffer} }, $characters->{Data} ); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 46 | ▶ | sub end_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 46 | my ( $self, $element ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 46 | ▶ | if ( $self->{skip} > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->{skip}--; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 46 | my $stack_element = pop( @{ $self->{element_stack} } ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 46 | my $name = $stack_element->{name}; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 46 | my $attrs = $stack_element->{attrs}; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 46 | my $spec = $stack_element->{spec}; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 46 | my $path = $stack_element->{spec_path}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 46 | my $result = $stack_element->{result}; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 46 | ▶ | if ( defined( $spec->{$path} ) && scalar( @{ $self->{buffer} } ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
defined $spec->{$path} and scalar @{$self->{"buffer"};}
MC/DC100%1/1
defined $spec->{$path} and scalar @{$self->{"buffer"};}
defined $spec->{$path}
Truth table100%2/2
A
A= defined $spec->{$path}
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 20 | my $buffer_data = join( '', @{ $self->{buffer} } ); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 20 | $buffer_data =~ s/^\s*//; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 20 | $buffer_data =~ s/\s*$//; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 20 | _add_value( $result, $spec->{$path}, $buffer_data ); | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 46 | foreach my $attr ( values(%$attrs) ) { | |||||||||||||||||||||||||||||||||||||||||
| 146 | 89 | my $ns_uri = $attr->{NamespaceURI}; | |||||||||||||||||||||||||||||||||||||||||
| 147 | my $attr_path = join( '', | ||||||||||||||||||||||||||||||||||||||||||
| 148 | $path, '/@', ( $ns_uri && $spec->{$ns_uri} ? "$spec->{$ns_uri}:" : '' ), | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 89 | ▶ | $attr->{LocalName} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ns_uri and $spec->{$ns_uri}
MC/DC100%2/2
$ns_uri and $spec->{$ns_uri}
$ns_uri
$spec->{$ns_uri}
Truth table100%3/3
A and B
A= $ns_uriB= $spec->{$ns_uri}
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 89 | ▶ | if ( $spec->{$attr_path} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 67 | _add_value( $result, $spec->{$attr_path}, $attr->{Value} ); | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 46 | ▶ | if ( !$path && scalar( @{ $self->{element_stack} } ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
not $path and scalar @{$self->{"element_stack"};}
MC/DC100%1/1
not $path and scalar @{$self->{"element_stack"};}
not $path
Truth table100%2/2
not(A)
A= not $path
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 23 | my $parent_element = $self->{element_stack}[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 158 | 23 | my $path_in_parent = "$parent_element->{spec_path}/$name"; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 23 | _add_value( $parent_element->{result}, $parent_element->{spec}{$path_in_parent}, | |||||||||||||||||||||||||||||||||||||||||
| 160 | $result ); | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 46 | $self->{buffer} = []; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 12 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 12 | my ( $self, $spec, $result ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 12 | ▶ | $self->{result} = $result || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result || {}
MC/DC0%0/1
$result || {}
$result
Truth table50%1/2
A
A= $result
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | $self->{element_stack} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 171 | { spec => $spec, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | spec_path => '', | ||||||||||||||||||||||||||||||||||||||||||
| 173 | result => $self->{result} | ||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | $self->{buffer} = []; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 12 | $self->{skip} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 35 | ▶ | sub _spec_prefix { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spec_prefix: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 35 | my ( $self, $uri ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 35 | ▶ | for ( my $i = scalar( @{ $self->{element_stack} } ) - 1; $i >= 0; $i-- ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 39 | my $spec_prefix = $self->{element_stack}[$i]->{spec}{$uri}; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 39 | ▶ | return $spec_prefix if ( defined($spec_prefix) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 46 | ▶ | sub start_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_element: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 46 | my ( $self, $element ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 46 | ▶ | if ( $self->{skip} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->{skip}++; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 46 | my $stack_top = $self->{element_stack}[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 46 | my $spec = $stack_top->{spec}; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 46 | my $result = $stack_top->{result}; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 46 | my $uri = $element->{NamespaceURI}; | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 46 | my $qname; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 46 | ▶ | if ($uri) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 35 | my $spec_prefix = $self->_spec_prefix($uri); | |||||||||||||||||||||||||||||||||||||||||
| 209 | 35 | ▶ | if ( !defined($spec_prefix) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # uri is not in spec, so nothing could possibly match | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $self->{skip} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | elsif ( $spec_prefix eq '' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 27 | $qname = $element->{LocalName}; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 8 | $qname = "$spec_prefix:$element->{LocalName}"; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 11 | $qname = $element->{LocalName}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 46 | my $spec_path = "$stack_top->{spec_path}/$qname"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 46 | ▶ | if ( defined( $spec->{$spec_path} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $spec->{$spec_path} and ref $spec->{$spec_path} eq "HASH" and defined $spec->{$spec_path}{"spec"}
defined $spec->{$spec_path} and ref $spec->{$spec_path} eq "HASH"
MC/DC66%2/3
defined $spec->{$spec_path} and ref $spec->{$spec_path} eq "HASH" and defined $spec->{$spec_path}{"spec"}
defined $spec->{$spec_path}
ref $spec->{$spec_path} eq "HASH"
defined $spec->{$spec_path}{"spec"}
Truth table75%3/4
A and B and C
A= defined $spec->{$spec_path}B= ref $spec->{$spec_path} eq "HASH"C= defined $spec->{$spec_path}{"spec"}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | && ref( $spec->{$spec_path} ) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||
| 229 | && defined( $spec->{$spec_path}{spec} ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 23 | $spec = $spec->{$spec_path}{spec}; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 23 | $spec_path = ''; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 23 | $result = {}; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | push( | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 46 | @{ $self->{element_stack} }, | |||||||||||||||||||||||||||||||||||||||||
| 238 | { name => $qname, | ||||||||||||||||||||||||||||||||||||||||||
| 239 | attrs => $element->{Attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 46 | spec => $spec, | |||||||||||||||||||||||||||||||||||||||||
| 241 | spec_path => $spec_path, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | result => $result | ||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | __END__ | ||||||||||||||||||||||||||||||||||||||||||