| 1 | 5 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | no warnings qw( once void uninitialized ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use IO::Handle 0 qw(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | package XML::LibXML::PrettyPrint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use constant { FALSE => 0, TRUE => 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use constant { EL_BLOCK => 1, EL_COMPACT => 2, EL_INLINE => 3}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | $XML::LibXML::PrettyPrint::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | $XML::LibXML::PrettyPrint::VERSION = '0.006'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use Carp 0 qw(croak carp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use Scalar::Util 0 qw(blessed refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use XML::LibXML 1.62 qw(:ns); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use Exporter::Tiny (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | our @ISA = 'Exporter::Tiny'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | our @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | our @EXPORT_OK = qw(print_xml EL_BLOCK EL_COMPACT EL_INLINE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | our %EXPORT_TAGS = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | constants => [qw(EL_BLOCK EL_COMPACT EL_INLINE)], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | ▶ | io => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | *IO::Handle::print_xml = sub ($$;$) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | my ($handle, $xml, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | unless (blessed($xml)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | local $@ = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | eval { $xml = XML::LibXML->new->parse_string($xml); 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | or croak("Could not parse XML: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | ▶ | $indent = 0 unless defined $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | $handle->print(__PACKAGE__->pretty_print($xml, $indent)->toString); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | our $Whitespace = qr/[\x20\t\r\n]/; # @@TODO need to check XML spec | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 30 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 30 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 30 | ▶ | $options{element} = delete $options{elements} unless defined $options{element}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 30 | ▶ | if (defined $options{indent_string}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | carp("Non-whitespace indent_string supplied") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | unless $options{indent_string} =~ /^$Whitespace*$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 30 | bless \%options, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | my @compact = qw[area audio base basefont bgsound br button canvas | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | caption col command dd details dt embed figcaption | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | frame h1 h2 h3 h4 h5 h6 hr iframe img input isindex | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | keygen legend li link meta option p param summary td | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | th title video]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | my @inline = qw[a abbr b bdi bdo big cite code dfn em font i kbd label | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | mark meter nobr progress q rp rt ruby s samp small span | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | strike strong sub sup time tt u var wbr]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | my @block = qw[address applet article aside blockquote body center | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | colgroup datalist del dir div fieldset figure footer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | form frameset head header hgroup html ins listing map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | marquee menu nav noembed noframes noscript object ol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | optgroup select section source table tbody tfoot thead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | tr track ul dl]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | my @pre = qw[plaintext output pre script style textarea xmp]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | my $rdfa_lit_content = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my ($el) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | return TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$el->hasAttribute("property") and not $el->hasAttribute("content")
MC/DC0%0/2
$el->hasAttribute("property") and not $el->hasAttribute("content")
$el->hasAttribute("property")
not $el->hasAttribute("content")
Truth table0%0/3
A and not(B)
A= $el->hasAttribute("property")B= not $el->hasAttribute("content")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | if ($el->hasAttribute('property') and not $el->hasAttribute('content')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | sub new_for_html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_for_html: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my ($class, %options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | %options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | element => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | block => [@block], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | compact => [@compact], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | inline => [@inline], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | preserves_whitespace => [@pre, $rdfa_lit_content], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | sub _ensure_self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ensure_self: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 898 | ▶ | blessed($_[0]) ? $_[0] : $_[0]->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | sub strip_whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 129 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strip_whitespace: called CC=23 SCAR=31.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 129 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 129 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 129 | ▶ | croak("First parameter must be an XML::LibXML::Node") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($node) and $node->isa("XML::LibXML::Node")
MC/DC0%0/2
builtin::blessed($node) and $node->isa("XML::LibXML::Node")
builtin::blessed($node)
$node->isa("XML::LibXML::Node")
Truth table33%1/3
A and B
A= builtin::blessed($node)B= $node->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | unless blessed($node) && $node->isa('XML::LibXML::Node'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 129 | ▶ | if ($node->nodeName eq '#document') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 29 | return $self->strip_whitespace($node->documentElement); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | elsif ($node->isa('XML::LibXML::Element')) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 87 | ▶ | if ($self->element_preserves_whitespace($node)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 84 | my $node_category = $self->element_category($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 84 | $node->normalize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 84 | my @kids = $node->childNodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 84 | my $activity = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 84 | ▶ | for (my $i = 0; exists $kids[$i]; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 180 | my $kid = $kids[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 180 | ▶ | if ($kid->nodeName eq '#text') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 109 | ▶ | my $prev = exists $kids[$i-1] ? $kids[$i-1] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 109 | ▶ | my $next = exists $kids[$i+1] ? $kids[$i+1] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 109 | my $data = $kid->data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 109 | ▶ | if ((defined $prev and $self->element_category($prev)==EL_INLINE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $prev and $self->element_category($prev) == 3 or $node_category == 3 and not defined $prev
defined $prev and $self->element_category($prev) == 3
$node_category == 3 and not defined $prev
MC/DC25%1/4
defined $prev and $self->element_category($prev) == 3 or $node_category == 3 and not defined $prev
defined $prev
$self->element_category($prev) == 3
$node_category == 3
not defined $prev
Truth table42%3/7
A and B or C and not(D)
A= defined $prevB= $self->element_category($prev) == 3C= $node_category == 3D= not defined $prev
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | or ($node_category==EL_INLINE and not defined $prev)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 17 | { $data =~ s/^$Whitespace+/ /; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 92 | { $data =~ s/^$Whitespace+//; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 109 | ▶ | if ((defined $next and $self->element_category($next)==EL_INLINE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
defined $next and $self->element_category($next) == 3 or $node_category == 3 and not defined $next
defined $next and $self->element_category($next) == 3
$node_category == 3 and not defined $next
MC/DC75%3/4
defined $next and $self->element_category($next) == 3 or $node_category == 3 and not defined $next
defined $next
$self->element_category($next) == 3
$node_category == 3
not defined $next
Truth table57%4/7
A and B or C and not(D)
A= defined $nextB= $self->element_category($next) == 3C= $node_category == 3D= not defined $next
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | or ($node_category==EL_INLINE and not defined $next)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 34 | { $data =~ s/$Whitespace+$/ /; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 75 | { $data =~ s/$Whitespace+$//; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 109 | $data =~ s/$Whitespace+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 109 | ▶ | $activity++ if length $data ne length $kid->data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 109 | ▶ | $node->removeChild($kid) unless length $data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 109 | $kid->setData($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 71 | $activity += $self->strip_whitespace($kid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 84 | return $activity; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 13 | ▶ | carp(sprintf("Don't know how to handle %s object", ref $node)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$node->nodeName eq "#comment" or $node->isa("XML::LibXML::CDATASection") or $node->isa("XML::LibXML::PI")
$node->nodeName eq "#comment" or $node->isa("XML::LibXML::CDATASection")
MC/DC0%0/3
$node->nodeName eq "#comment" or $node->isa("XML::LibXML::CDATASection") or $node->isa("XML::LibXML::PI")
$node->nodeName eq "#comment"
$node->isa("XML::LibXML::CDATASection")
$node->isa("XML::LibXML::PI")
Truth table75%3/4
A or B or C
A= $node->nodeName eq "#comment"B= $node->isa("XML::LibXML::CDATASection")C= $node->isa("XML::LibXML::PI")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | unless $node->nodeName eq '#comment' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | || $node->isa('XML::LibXML::CDATASection') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | || $node->isa('XML::LibXML::PI'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 13 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | sub indent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 103 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indent: called CC=22 SCAR=30.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 103 | my ($self, $node, $indent_level) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 103 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 103 | ▶ | $indent_level = 0 unless defined $indent_level; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 103 | ▶ | $self->indent($node->documentElement, $indent_level) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($node) and $node->nodeName eq "#document"
MC/DC50%1/2
builtin::blessed($node) and $node->nodeName eq "#document"
builtin::blessed($node)
$node->nodeName eq "#document"
Truth table66%2/3
A and B
A= builtin::blessed($node)B= $node->nodeName eq "#document"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | if blessed($node) && $node->nodeName eq '#document'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 103 | ▶ | return unless blessed($node) && $node->isa('XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($node) and $node->isa("XML::LibXML::Element")
MC/DC50%1/2
builtin::blessed($node) and $node->isa("XML::LibXML::Element")
builtin::blessed($node)
$node->isa("XML::LibXML::Element")
Truth table66%2/3
A and B
A= builtin::blessed($node)B= $node->isa("XML::LibXML::Element")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 59 | ▶ | return if $self->element_preserves_whitespace($node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 58 | my $node_category = $self->element_category($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # EL_COMPACT nodes get treated as inline unless they contain a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # block descendent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 58 | ▶ | if ($node_category==EL_COMPACT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 14 | $node_category = EL_INLINE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | my $descs = $node->getElementsByTagName('*'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | ▶ | DESC: while (my $desc = $descs->shift) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 10 | ▶ | if ($self->element_category($desc) == EL_BLOCK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 3 | $node_category = EL_BLOCK; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 3 | last DESC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 58 | ▶ | if ($node_category==EL_BLOCK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 39 | my $newline = $self->new_line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 39 | my $indent_string = $self->indent_string($indent_level + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 39 | my @kids = $node->childNodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 39 | $node->removeChildNodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 39 | ▶ | for (my $i = 0; exists $kids[$i]; $i++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 73 | my $kid = $kids[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 73 | my $did_indent = FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 73 | ▶ | if ($i==0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 28 | $node->appendText($newline . $indent_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 28 | $did_indent = TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | elsif ($self->element_category($kid)==EL_BLOCK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 13 | $node->appendText($newline . $indent_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 13 | $did_indent = TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | elsif ($self->element_category($kid)==EL_COMPACT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 13 | $node->appendText($newline . $indent_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 13 | $did_indent = TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | elsif (defined $kids[$i-1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 19 | my $prev_category = $self->element_category($kids[$i-1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 19 | ▶ | if (defined $prev_category | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $prev_category and $prev_category == 1 || $prev_category == 2
$prev_category == 1 or $prev_category == 2
MC/DC100%3/3
defined $prev_category and $prev_category == 1 || $prev_category == 2
defined $prev_category
$prev_category == 1
$prev_category == 2
Truth table100%4/4
A and B or C
A= defined $prev_categoryB= $prev_category == 1C= $prev_category == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | and ($prev_category==EL_BLOCK or $prev_category==EL_COMPACT)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | $node->appendText($newline . $indent_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | $did_indent = TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 73 | ▶ | if ($did_indent and $kid->nodeName eq '#text') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$did_indent and $kid->nodeName eq "#text"
MC/DC100%2/2
$did_indent and $kid->nodeName eq "#text"
$did_indent
$kid->nodeName eq "#text"
Truth table100%3/3
A and B
A= $did_indentB= $kid->nodeName eq "#text"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 14 | (my $data = $kid->data) =~ s/^ //; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 14 | $kid->setData($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 73 | $node->appendChild($kid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 73 | $self->indent($kid, $indent_level + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 39 | ▶ | $node->appendText($newline . $self->indent_string($indent_level)) if @kids; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | sub pretty_print | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty_print: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | my ($self, $node, $indent_level) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 4 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 4 | $self->strip_whitespace($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | $self->indent($node, $indent_level); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 4 | return $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | sub _run_checks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1294 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_checks: called CC=14 SCAR=37.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1294 | my ($self, $category, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1294 | ▶ | return FALSE unless defined $self->{element}{$category}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 383 | ▶ | if (ref $self->{element}{$category} eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $self->{"element"}{$category} eq "CODE" or not ref $self->{"element"}{$category}
MC/DC0%0/2
ref $self->{"element"}{$category} eq "CODE" or not ref $self->{"element"}{$category}
ref $self->{"element"}{$category} eq "CODE"
not ref $self->{"element"}{$category}
Truth table33%1/3
A or not(B)
A= ref $self->{"element"}{$category} eq "CODE"B= not ref $self->{"element"}{$category}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | or !ref $self->{element}{$category}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $self->{element}{$category} = [$self->{element}{$category}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 383 | ▶ | if (ref $self->{element}{$category} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 383 | foreach my $check (@{$self->{element}{$category}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 902 | ▶ | if (!ref $check and $check =~ /^\{(.+)\}(.+)$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
not ref $check and $check =~ /^\{(.+)\}(.+)$/
MC/DC0%0/2
not ref $check and $check =~ /^\{(.+)\}(.+)$/
not ref $check
$check =~ /^\{(.+)\}(.+)$/
Truth table33%1/3
not(A) and B
A= not ref $checkB= $check =~ /^\{(.+)\}(.+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | return TRUE if $node->namespaceURI eq $1 && $node->localname eq $2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$node->namespaceURI eq $1 and $node->localname eq $2
MC/DC0%0/2
$node->namespaceURI eq $1 and $node->localname eq $2
$node->namespaceURI eq $1
$node->localname eq $2
Truth table0%0/3
A and B
A= $node->namespaceURI eq $1B= $node->localname eq $2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | elsif (!ref $check) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 902 | ▶ | return TRUE if $check eq $node->nodeName; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | elsif (ref $check eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $return = $check->($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | return $return if defined $return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | carp(sprintf("Check for category '%s' ignored; is of type %s", $category, ref $check)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 207 | return FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | sub indent_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 67 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indent_string: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 67 | my ($self, $level) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 67 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | $self->{indent_string} = "\t" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 67 | ▶ | unless defined $self->{indent_string}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 67 | $self->{indent_string} x $level; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | sub new_line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 39 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_line: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 39 | my ($self, $level) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 39 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | $self->{new_line} = "\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 39 | ▶ | unless defined $self->{new_line}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 39 | $self->{new_line}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | sub element_category | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 410 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_category: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 410 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 410 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 410 | ▶ | return undef unless blessed($node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 410 | ▶ | return EL_BLOCK if $self->_run_checks(block => $node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 410 | ▶ | return EL_COMPACT if $self->_run_checks(compact => $node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 328 | ▶ | return EL_INLINE if $self->_run_checks(inline => $node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 238 | ▶ | return EL_BLOCK if $node->isa('XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 102 | ▶ | return EL_COMPACT if $node->nodeName eq '#comment'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 90 | ▶ | return EL_COMPACT if $node->isa('XML::LibXML::PI'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 84 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | sub element_preserves_whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 146 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_preserves_whitespace: called CC=9 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 146 | my ($self, $node) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 146 | $self = $self->_ensure_self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 146 | ▶ | return undef unless blessed($node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 146 | ▶ | return TRUE if $node->nodeName eq '#comment'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 146 | ▶ | return TRUE if $node->isa('XML::LibXML::PI'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 146 | ▶ | return TRUE if $self->_run_checks(preserves_whitespace => $node); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 142 | ▶ | return TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$node->isa("XML::LibXML::Element") and $node->hasAttributeNS("http://www.w3.org/XML/1998/namespace", "space") and lc $node->getAttributeNS("http://www.w3.org/XML/1998/namespace", "space") eq "preserve"
$node->isa("XML::LibXML::Element") and $node->hasAttributeNS("http://www.w3.org/XML/1998/namespace", "space")
MC/DC0%0/3
$node->isa("XML::LibXML::Element") and $node->hasAttributeNS("http://www.w3.org/XML/1998/namespace", "space") and lc $node->getAttributeNS("http://www.w3.org/XML/1998/namespace", "space") eq "preserve"
$node->isa("XML::LibXML::Element")
$node->hasAttributeNS("http://www.w3.org/XML/1998/namespace", "space")
lc $node->getAttributeNS("http://www.w3.org/XML/1998/namespace", "space") eq "preserve"
Truth table25%1/4
A and B and C
A= $node->isa("XML::LibXML::Element")B= $node->hasAttributeNS("http://www.w3.org/XML/1998/namespace", "space")C= lc $node->getAttributeNS("http://www.w3.org/XML/1998/namespace", "space") eq "preserve"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | if $node->isa('XML::LibXML::Element') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | && $node->hasAttributeNS(XML_XML_NS, 'space') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | && lc $node->getAttributeNS(XML_XML_NS, 'space') eq 'preserve'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 142 | ▶ | return FALSE if $node->isa('XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub print_xml ($;$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_xml: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | my ($xml, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | unless (blessed($xml)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | local $@ = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | eval { $xml = XML::LibXML->new->parse_string($xml); 1; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | or croak("Could not parse XML: $@"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $indent = 0 unless defined $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | print __PACKAGE__->pretty_print($xml, $indent)->toString; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||