Branch Coverage

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


line true false branch
47 0 84 if defined $opts->{'parser'}
55 0 84 @_ > 1 && &blessed($_[0]) && $_[0]->isa('XML::LibXML::Simple') ? :
62 0 79 unless my $xml = $self->_get_xml($target, $opts)
65 0 79 if (my $cb = $opts->{'hooknodes'})
70 1 78 if ($opts->{'keeproot'})
72 1 0 $opts->{'forcearray_always'} && ref $top ne 'ARRAY' ? :
83 1 81 unless defined $source
86 1 81 if $source eq '-'
100 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')) ? :
102 79 0 if $xml->isa('XML::LibXML::Document')
110 82 0 ref $_[0] eq 'HASH' ? :
0 82 @_ != 1 ? :
128 1 167 unless @_ % 2 == 0
135 1 118 unless $known_opts{$lkey}
151 1 0 if $script_dir
161 48 34 if (defined $opt{'contentkey'}) { }
169 2 80 unless ref $opt{'searchpath'} eq 'ARRAY'
173 6 76 if (ref $fa) { }
174 5 1 ref $fa eq 'ARRAY' ? :
175 3 5 if (ref $_ eq 'Regexp') { }
187 3 79 unless ref $ka
189 62 20 if (ref $ka eq 'ARRAY') { }
20 0 elsif (ref $ka eq 'HASH') { }
190 60 2 if (@$ka) { }
207 2 80 if ref $va eq 'ARRAY'
212 0 82 unless not $opt{'grouptags'} or ref $opt{'grouptags'} eq 'HASH'
222 4 3 @_ ? :
226 4 3 if ($filename eq $file) { }
2 1 elsif (-e $file) { }
229 2 4 if -e $fullpath
243 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'};})) { }
245 46 51 if (ref $d->{$k} eq 'ARRAY') { }
265 0 0 length $uri ? :
270 0 383 unless $xml->isa('XML::LibXML::Element')
275 366 17 unless ($opts->{'noattr'})
281 0 236 if ($hooks and my $hook = $$hooks{$attr->unique_key}) { }
283 0 0 unless defined $value
290 2 234 if not ref $value and $opts->{'normalisespace'} == 2
295 0 236 $opts->{'nsstrip'} ? :
0 236 $opts->{'nsexpand'} ? :
0 236 !$attr->isa('XML::LibXML::Attr') ? :
307 536 304 if ($child->isa('XML::LibXML::Text'))
312 0 304 unless $child->isa('XML::LibXML::Element')
318 0 304 if ($hooks and my $hook = $$hooks{$child->unique_key}) { }
323 0 0 if not defined $v and $opts->{'suppressempty'}
327 0 304 $opts->{'nsstrip'} ? :
0 304 $opts->{'nsexpand'} ? :
334 14 369 if defined $text and $opts->{'normalisespace'} == 2
336 2 134 $opts->{'forcecontent'} ? :
136 247 if $nr_attrs + $nr_elems == 0 and defined $text
339 34 213 if defined $text and $nr_elems == 0
344 101 146 if (keys %data == 1)
346 7 94 if $opts->{'valueattrlist'}{$k}
351 233 7 if ($opts->{'keyattr'})
353 84 375 if ref $val eq 'ARRAY'
360 21 219 if (my $gr = $opts->{'grouptags'})
364 35 8 unless my $sub = $gr->{$key}
365 0 8 if (ref $val eq 'ARRAY') { }
367 0 0 unless keys %$_ != 1
0 0 if grep {not exists $_->{$sub} unless keys %$_ != 1;} @$val
371 0 8 unless ref $val eq 'HASH' and keys %$val == 1
374 7 1 if $gr->{$key} eq $child_key
383 12 82 if keys %data == 1 and exists $data{'anon'} and ref $data{'anon'} eq 'ARRAY'
386 0 2 if (not keys %data and exists $opts->{'suppressempty'})
388 0 0 defined $sup && $sup eq '' ? :
392 228 0 if (my $va = $opts->{'valueattrlist'})
394 0 4 unless $va->{$key} and ref $val eq 'HASH' and keys %$val == 1
401 0 0 $opts->{'forcecontent'} ? :
2 0 !defined($text) ? :
226 2 $nr_elems + $nr_attrs ? :
423 0 84 unless my $ka = $opts->{'keyattr'}
425 28 56 if (ref $ka eq 'HASH') { }
426 8 20 unless my $newkey = $ka->{$name}
430 2 42 unless (ref $h eq 'HASH' and defined $h->{$key})
431 1 1 if $^W
436 2 40 if (ref $val)
437 1 1 if $^W
442 2 38 if $opts->{'normalisespace'} == 1
445 1 39 if $^W and defined $out{$val}
448 4 36 if $flag eq '-'
449 38 2 if $flag ne '+'
458 28 50 unless ref $h eq 'HASH'
462 39 42 unless defined $val
464 2 40 if (ref $val)
465 1 1 if $^W and not $default_keys
471 2 38 if $opts->{'normalisespace'} == 1
474 1 3 if $^W and $out{$val}
485 7 27 unless $opts->{'collapseagain'}
500 0 35 unless defined $v
501 14 5 if ref $v eq 'HASH' and keys %$v == 1 and exists $v->{$contentkey}
502 0 21 if ref $v eq 'HASH' and not keys %$v