| 1 | package XML::TreePuller; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 7 | our $VERSION = '0.1.3_01'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Carp qw(croak carp); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use XML::LibXML::Reader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use XML::TreePuller::Element; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use XML::TreePuller::Constants; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use XML::CompactTree; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 7 | our $NO_XS; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=16.4
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 7 | ▶ | if ($ENV{XML_TREEPULLER_NO_XS}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 0 | $NO_XS = $ENV{XML_TREEPULLER_NO_XS}; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 7 | ▶ | if (! $NO_XS && ! defined(eval { require XML::CompactTree::XS; })) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$XML::TreePuller::NO_XS || defined eval {
do {
require XML::CompactTree::XS
}
}
MC/DC0%0/2
$XML::TreePuller::NO_XS || defined eval {
do {
require XML::CompactTree::XS
}
}
$XML::TreePuller::NO_XS
defined eval {
do {
require XML::CompactTree::XS
}
}
Truth table33%1/3
A || B
A= $XML::TreePuller::NO_XSB= defined eval {
do {
require XML::CompactTree::XS
}
}
| |||||||||||||||||||||||||||||
| 25 | 7 | $NO_XS = 1; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | 7 | my ($class, @args) = @_; | |||||||||||||||||||||||||||
| 32 | 7 | my $self = {}; | |||||||||||||||||||||||||||
| 33 | 7 | my $reader; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 7 | bless($self, $class); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 7 | $self->{elements} = []; | |||||||||||||||||||||||||||
| 38 | 7 | $self->{config} = {}; | |||||||||||||||||||||||||||
| 39 | 7 | $self->{finished} = 0; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 7 | $Carp::CarpLevel++; | |||||||||||||||||||||||||||
| 42 | 7 | $reader = $self->{reader} = XML::LibXML::Reader->new(@args); | |||||||||||||||||||||||||||
| 43 | 7 | $Carp::CarpLevel--; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | #arg how do you get error messages out of libxml reader? | ||||||||||||||||||||||||||||
| 46 | 7 | ▶ | croak("could not construct libxml reader") unless defined $reader; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 7 | return $self; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub parse { | ||||||||||||||||||||||||||
|
Subroutine
parse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 52 | 1 | my ($class, @args) = @_; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 1 | return $class->new(@args)->next; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 7 | ▶ | sub iterate_at { | ||||||||||||||||||||||||||
|
Subroutine
iterate_at: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 7 | my ($self, $path, $todo) = @_; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 7 | ▶ | croak("must specify match and instruction") unless defined $path && defined $todo; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $path and defined $todo
MC/DC0%0/2
defined $path and defined $todo
defined $path
defined $todo
Truth table33%1/3
A and B
A= defined $pathB= defined $todo
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 7 | $self->{config}->{$path} = $todo; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 7 | return undef; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub config { | ||||||||||||||||||||||||||
|
Subroutine
config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 68 | #turn this warning on later | ||||||||||||||||||||||||||||
| 69 | #carp "config() is depreciated, use iterate_at() instead"; | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | return iterate_at(@_); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 16 | ▶ | sub next { | ||||||||||||||||||||||||||
|
Subroutine
next: called CC=12 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 16 | my ($self) = @_; | |||||||||||||||||||||||||||
| 76 | 16 | my $reader = $self->{reader}; | |||||||||||||||||||||||||||
| 77 | 16 | my $elements = $self->{elements}; | |||||||||||||||||||||||||||
| 78 | 16 | my $config = $self->{config}; | |||||||||||||||||||||||||||
| 79 | 16 | my $ret; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 16 | ▶ | return () if $self->{finished}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 16 | ▶ | if ($reader->nodeType != XML_READER_TYPE_ELEMENT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 15 | ▶ | if (! $self->_find_next_element) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | #no more elements available in the document | ||||||||||||||||||||||||||||
| 86 | 2 | return (); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | #the reader came in already sitting on an element so we have to | ||||||||||||||||||||||||||||
| 91 | #iterate at the end of the loop | ||||||||||||||||||||||||||||
| 92 | 14 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 27 | my $path; | |||||||||||||||||||||||||||
| 94 | my $todo; | ||||||||||||||||||||||||||||
| 95 | 27 | my $ret; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 27 | ▶ | if(! $self->_sync) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | #ran out of data in the document | ||||||||||||||||||||||||||||
| 99 | 0 | return (); | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 27 | push(@$elements, $reader->name); | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 27 | $path = '/' . join('/', @$elements); | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | #handle the default case where no config is specified | ||||||||||||||||||||||||||||
| 107 | 27 | ▶ | if (scalar(keys(%$config)) == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 2 | $self->{finished} = 1; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 2 | ▶ | if (wantarray()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | return($path, $self->_read_subtree); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 2 | return $self->_read_subtree; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | #if this is converted over a dispatch hash then | ||||||||||||||||||||||||||||
| 118 | #the keys in the hash can be used to validate items | ||||||||||||||||||||||||||||
| 119 | #as they are passed to next() and allow this | ||||||||||||||||||||||||||||
| 120 | #method to scale to more instructions | ||||||||||||||||||||||||||||
| 121 | 25 | ▶ | if (defined($todo = $config->{$path})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 10 | ▶ | if ($todo eq 'short') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 123 | 6 | $ret = $self->_read_element; | |||||||||||||||||||||||||||
| 124 | } elsif ($todo eq 'subtree') { | ||||||||||||||||||||||||||||
| 125 | 4 | $ret = $self->_read_subtree; | |||||||||||||||||||||||||||
| 126 | } else { | ||||||||||||||||||||||||||||
| 127 | 0 | die "invalid todo specified: $todo"; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 10 | ▶ | if (wantarray()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 5 | return($path, $ret); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 5 | return $ret; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | } while ($self->_find_next_element); | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 2 | return (); | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 2 | ▶ | sub reader { | ||||||||||||||||||||||||||
|
Subroutine
reader: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 2 | return $_[0]->{reader}; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | #private methods | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | #get the reader to a point where it is in sync with | ||||||||||||||||||||||||||||
| 149 | #our internal element list | ||||||||||||||||||||||||||||
| 150 | 27 | ▶ | sub _sync { | ||||||||||||||||||||||||||
|
Subroutine
_sync: called CC=4 SCAR=19.1
| |||||||||||||||||||||||||||||
| 151 | 27 | my ($self) = @_; | |||||||||||||||||||||||||||
| 152 | 27 | my $reader = $self->{reader}; | |||||||||||||||||||||||||||
| 153 | 27 | my $depth = $self->{reader}->depth; | |||||||||||||||||||||||||||
| 154 | 27 | my $elements = $self->{elements}; | |||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | #if we are at a higher level than we have | ||||||||||||||||||||||||||||
| 157 | #tracked to we need to get back to the same | ||||||||||||||||||||||||||||
| 158 | #depth as our element list to properly process | ||||||||||||||||||||||||||||
| 159 | #data again | ||||||||||||||||||||||||||||
| 160 | 27 | ▶ | while(scalar(@$elements) < $reader->depth) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | my $ret = $reader->nextElement; | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ($ret == -1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 164 | 0 | die "libxml read error"; | |||||||||||||||||||||||||||
| 165 | } elsif ($ret == 0) { | ||||||||||||||||||||||||||||
| 166 | 0 | $self->{finished} = 1; | |||||||||||||||||||||||||||
| 167 | 0 | return 0; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | #handle the case where the reader is at a lower | ||||||||||||||||||||||||||||
| 172 | #depth than we have tracked to | ||||||||||||||||||||||||||||
| 173 | 27 | splice(@$elements, $reader->depth); | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 27 | return 1; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 30 | ▶ | sub _find_next_element { | ||||||||||||||||||||||||||
|
Subroutine
_find_next_element: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 180 | 30 | my ($self) = @_; | |||||||||||||||||||||||||||
| 181 | 30 | my $reader = $self->{reader}; | |||||||||||||||||||||||||||
| 182 | 30 | my $ret; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 30 | ▶ | if (! ($ret = $reader->nextElement)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 185 | 4 | $self->{finished} = 1; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 4 | return 0; | |||||||||||||||||||||||||||
| 188 | } elsif ($ret == -1) { | ||||||||||||||||||||||||||||
| 189 | 0 | die "libxml read error"; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 26 | return 1; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 6 | ▶ | sub _read_subtree { | ||||||||||||||||||||||||||
|
Subroutine
_read_subtree: called CC=2 SCAR=7.5
| |||||||||||||||||||||||||||||
| 196 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 197 | 6 | my $reader = $self->{reader}; | |||||||||||||||||||||||||||
| 198 | 6 | my $elements = $self->{elements}; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 6 | my $tree = XML::TreePuller::Element->new(_read_tree($reader)); | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 6 | ▶ | if (! defined($tree)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | 0 | $self->{finished} = 1; | |||||||||||||||||||||||||||
| 204 | 0 | return undef; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 6 | return $tree; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 6 | ▶ | sub _read_element { | ||||||||||||||||||||||||||
|
Subroutine
_read_element: called CC=13 SCAR=26.4
| |||||||||||||||||||||||||||||
| 211 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 212 | 6 | my $reader = $self->{reader}; | |||||||||||||||||||||||||||
| 213 | 6 | my $is_empty = $reader->isEmptyElement; | |||||||||||||||||||||||||||
| 214 | 6 | my $new; | |||||||||||||||||||||||||||
| 215 | my %attr; | ||||||||||||||||||||||||||||
| 216 | 6 | my $node_type; | |||||||||||||||||||||||||||
| 217 | 6 | my $ret; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 6 | $new->[XML_TREEPULLER_ELEMENT_TYPE] = 1; | |||||||||||||||||||||||||||
| 220 | 6 | $new->[XML_TREEPULLER_ELEMENT_NAME] = $reader->name; | |||||||||||||||||||||||||||
| 221 | 6 | $new->[XML_TREEPULLER_ELEMENT_NAMESPACE] = 0; | |||||||||||||||||||||||||||
| 222 | 6 | $new->[XML_TREEPULLER_ELEMENT_ATTRIBUTES] = \%attr; | |||||||||||||||||||||||||||
| 223 | 6 | $new->[XML_TREEPULLER_ELEMENT_CHILDREN] = []; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 6 | ▶ | if ($reader->hasAttributes && $reader->moveToFirstAttribute == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$reader->hasAttributes and $reader->moveToFirstAttribute == 1
MC/DC50%1/2
$reader->hasAttributes and $reader->moveToFirstAttribute == 1
$reader->hasAttributes
$reader->moveToFirstAttribute == 1
Truth table66%2/3
A and B
A= $reader->hasAttributesB= $reader->moveToFirstAttribute == 1
| |||||||||||||||||||||||||||||
| 227 | 4 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 4 | my $name = $reader->name; | |||||||||||||||||||||||||||
| 229 | 4 | my $val = $reader->value; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 4 | $attr{$name} = $val; | |||||||||||||||||||||||||||
| 232 | } while($reader->moveToNextAttribute == 1); | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 6 | $ret = $reader->read; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 6 | ▶ | if ($ret == -1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 239 | 0 | die "libxml read error"; | |||||||||||||||||||||||||||
| 240 | } elsif ($ret == 0) { | ||||||||||||||||||||||||||||
| 241 | 0 | return undef; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 6 | ▶ | if ($is_empty) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | 1 | return XML::TreePuller::Element->new($new); | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 5 | $node_type = $reader->nodeType; | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 5 | ▶ | while($node_type != XML_READER_TYPE_ELEMENT && $node_type != XML_READER_TYPE_END_ELEMENT) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$node_type != 1 and $node_type != 15
MC/DC100%2/2
$node_type != 1 and $node_type != 15
$node_type != 1
$node_type != 15
Truth table100%3/3
A and B
A= $node_type != 1B= $node_type != 15
| |||||||||||||||||||||||||||||
| 251 | 7 | $node_type = $reader->nodeType; | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 7 | ▶ | if ($node_type == XML_READER_TYPE_TEXT || $node_type == XML_READER_TYPE_CDATA) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$node_type == 3 or $node_type == 4
MC/DC50%1/2
$node_type == 3 or $node_type == 4
$node_type == 3
$node_type == 4
Truth table66%2/3
A or B
A= $node_type == 3B= $node_type == 4
| |||||||||||||||||||||||||||||
| 254 | 4 | push(@{$new->[XML_TREEPULLER_ELEMENT_CHILDREN]}, [ $node_type, $reader->value ]); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 7 | $ret = $reader->read; | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 7 | ▶ | if ($ret == -1) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 260 | 0 | die "libxml read error"; | |||||||||||||||||||||||||||
| 261 | } elsif ($ret == 0) { | ||||||||||||||||||||||||||||
| 262 | 0 | return undef; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 7 | $node_type = $reader->nodeType; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 5 | return XML::TreePuller::Element->new($new); | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 6 | ▶ | sub _read_tree { | ||||||||||||||||||||||||||
|
Subroutine
_read_tree: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 273 | 6 | my ($r) = @_; | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 6 | ▶ | if ($NO_XS) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 6 | return XML::CompactTree::readSubtreeToPerl($r, 0); | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 0 | return XML::CompactTree::XS::readSubtreeToPerl($r, 0); | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 7 | 1; | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | __END__ | ||||||||||||||||||||||||||||