Branch Coverage

lib/XML/LibXML/Simple.pm
Criterion Covered Total %
branch 149 194 76.8


line true false branch
43 0 84 if defined $opts->{'parser'}
51 0 84 @_ > 1 && &blessed($_[0]) && $_[0]->isa('XML::LibXML::Simple') ? :
58 0 79 unless my $xml = $self->_get_xml($target, $opts)
61 0 79 if (my $cb = $opts->{'hooknodes'})
66 1 78 if ($opts->{'keeproot'})
68 1 0 $opts->{'forcearray_always'} && ref $top ne 'ARRAY' ? :
79 1 81 unless defined $source
82 1 81 if $source eq '-'
96 73 7 $source =~ /^\s*\<.*?\>\s*$/s ? :
2 80 ref $source ? :
0 82 ref $source eq 'SCALAR' ? :
0 82 &blessed($source) && ($source->isa('XML::LibXML::Document') || $source->isa('XML::LibXML::Element')) ? :
98 79 0 if $xml->isa('XML::LibXML::Document')
106 82 0 ref $_[0] eq 'HASH' ? :
0 82 @_ != 1 ? :
124 1 167 unless @_ % 2 == 0
131 1 118 unless $known_opts{$lkey}
147 1 0 if $script_dir
157 48 34 if (defined $opt{'contentkey'}) { }
165 2 80 unless ref $opt{'searchpath'} eq 'ARRAY'
169 6 76 if (ref $fa) { }
170 5 1 ref $fa eq 'ARRAY' ? :
171 3 5 if (ref $_ eq 'Regexp') { }
183 3 79 unless ref $ka
185 62 20 if (ref $ka eq 'ARRAY') { }
20 0 elsif (ref $ka eq 'HASH') { }
186 60 2 if (@$ka) { }
203 2 80 if ref $va eq 'ARRAY'
208 0 82 unless not $opt{'grouptags'} or ref $opt{'grouptags'} eq 'HASH'
218 4 3 @_ ? :
222 4 3 if ($filename eq $file) { }
2 1 elsif (-e $file) { }
225 2 4 if -e $fullpath
239 97 443 if (defined $d->{$k}) { }
2 441 elsif (ref $v eq 'ARRAY') { }
24 417 elsif (ref $v eq 'HASH' and $k ne $opts->{'contentkey'} and $opts->{'forcearray_always'}) { }
12 405 elsif ($opts->{'forcearray_elem'}{$k} or grep(($k =~ /$_/), @{$$opts{'forcearray_regex'};})) { }
241 46 51 if (ref $d->{$k} eq 'ARRAY') { }
261 0 0 length $uri ? :
266 0 383 unless $xml->isa('XML::LibXML::Element')
271 366 17 unless ($opts->{'noattr'})
277 0 236 if ($hooks and my $hook = $$hooks{$attr->unique_key}) { }
279 0 0 unless defined $value
286 2 234 if not ref $value and $opts->{'normalisespace'} == 2
291 0 236 $opts->{'nsstrip'} ? :
0 236 $opts->{'nsexpand'} ? :
0 236 !$attr->isa('XML::LibXML::Attr') ? :
303 536 304 if ($child->isa('XML::LibXML::Text'))
308 0 304 unless $child->isa('XML::LibXML::Element')
314 0 304 if ($hooks and my $hook = $$hooks{$child->unique_key}) { }
319 0 0 if not defined $v and $opts->{'suppressempty'}
323 0 304 $opts->{'nsstrip'} ? :
0 304 $opts->{'nsexpand'} ? :
330 14 369 if defined $text and $opts->{'normalisespace'} == 2
332 2 134 $opts->{'forcecontent'} ? :
136 247 if $nr_attrs + $nr_elems == 0 and defined $text
335 34 213 if defined $text and $nr_elems == 0
340 101 146 if (keys %data == 1)
342 7 94 if $opts->{'valueattrlist'}{$k}
347 233 7 if ($opts->{'keyattr'})
349 84 375 if ref $val eq 'ARRAY'
356 21 219 if (my $gr = $opts->{'grouptags'})
360 35 8 unless my $sub = $gr->{$key}
361 0 8 if (ref $val eq 'ARRAY') { }
363 0 0 unless keys %$_ != 1
0 0 if grep {not exists $_->{$sub} unless keys %$_ != 1;} @$val
367 0 8 unless ref $val eq 'HASH' and keys %$val == 1
370 7 1 if $gr->{$key} eq $child_key
379 12 82 if keys %data == 1 and exists $data{'anon'} and ref $data{'anon'} eq 'ARRAY'
382 0 2 if (not keys %data and exists $opts->{'suppressempty'})
384 0 0 defined $sup && $sup eq '' ? :
388 228 0 if (my $va = $opts->{'valueattrlist'})
390 0 4 unless $va->{$key} and ref $val eq 'HASH' and keys %$val == 1
397 0 0 $opts->{'forcecontent'} ? :
2 0 !defined($text) ? :
226 2 $nr_elems + $nr_attrs ? :
419 0 84 unless my $ka = $opts->{'keyattr'}
421 28 56 if (ref $ka eq 'HASH') { }
422 8 20 unless my $newkey = $ka->{$name}
426 2 42 unless (ref $h eq 'HASH' and defined $h->{$key})
427 1 1 if $^W
432 2 40 if (ref $val)
433 1 1 if $^W
438 2 38 if $opts->{'normalisespace'} == 1
441 1 39 if $^W and defined $out{$val}
444 4 36 if $flag eq '-'
445 38 2 if $flag ne '+'
454 28 50 unless ref $h eq 'HASH'
458 39 42 unless defined $val
460 2 40 if (ref $val)
461 1 1 if $^W and not $default_keys
467 2 38 if $opts->{'normalisespace'} == 1
470 1 3 if $^W and $out{$val}
481 7 27 unless $opts->{'collapseagain'}
496 0 35 unless defined $v
497 14 4 if ref $v eq 'HASH' and keys %$v == 1 and exists $v->{$contentkey}
498 0 21 if ref $v eq 'HASH' and not keys %$v