XSH2/LibXMLCompat.pm

filter: Statementstmt 42.8% 116 / 271 Branchbran 20.0% 20 / 100 Conditioncond 4.4% 2 / 45 MC/DCmcdc 3.3% 1 / 30 Subroutinesub 46.6% 35 / 75 Podpod 2.1% 1 / 47 totaltotal 30.8% 175 / 568 CC 67 SCAR 35.8
CC
67
Cov
33%
subtree_iterator
240.0
get_dtd
75.7
add
12.2
CRAP 35.8
« XSH2/XPathToXML.pm ↑ Summary XSH2/Iterators.pm »
1 # -*- cperl -*-
2 # $Id: LibXMLCompat.pm,v 2.5 2007-04-02 13:19:55 pajas Exp $
3  
4 package XML::XSH2::LibXMLCompat;
5  
6 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use XML::LibXML::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use XML::LibXML::NodeList;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 8 $VERSION='2.2.10'; # VERSION TEMPLATE
13  
14 15 ▶sub module {
Subroutine module: called CC=1 SCAR=0.0
Pod undocumented
15 15 return "XML::LibXML";
16 }
17  
18 0 ▶sub version {
Subroutine version: not called CC=1 SCAR=6.9
Pod undocumented
19 0 return $XML::LibXML::VERSION;
20 }
21  
22 43 ▶sub toStringUTF8 {
Subroutine toStringUTF8: called CC=8 SCAR=24.0
Pod undocumented
23 43 my ($class,$node,$mode)=@_;
24 43 ▶ return unless $node;
Branch: 1 branch
BranchTrueFalseTotal
unless $node 0 43 43
25 43 ▶ $mode = 0 unless $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless $mode 1 42 43
26 43 ▶ if ($class->is_document($node)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($class->is_document($node)) { } 9 34 43
elsif ($class->is_namespace($node)) { } 0 34 34
elsif ($class->is_attribute($node)) { } 0 34 34
27 9 return XML::LibXML::encodeToUTF8($node->getEncoding(),$node->toString($mode));
28 } elsif ($class->is_namespace($node)) {
29 0 ▶ return 'xmlns'.($node->name() ne '' ? ':' : '').
Branch: 1 branch
BranchTrueFalseTotal
$node->name ne '' ? : 0 0 0
30 $node->name()."='".$node->getNamespaceURI()."'";
31 } elsif ($class->is_attribute($node)) {
32 0 return $node->name()."='".$node->value()."'";
33 } else {
34 34 ▶ return $node->can('toString') ?
Branch: 1 branch
BranchTrueFalseTotal
$node->can('toString') ? : 34 0 34
35 $node->toString($mode) :
36 $node->to_literal();
37 }
38 }
39  
40 15 ▶sub new_parser {
Subroutine new_parser: called CC=1 SCAR=0.0
Pod undocumented
41 15 return XML::LibXML->new();
42 }
43  
44 294 ▶sub owner_document {
Subroutine owner_document: called CC=2 SCAR=6.9
Pod undocumented
45 294 my ($self,$node)=@_;
46 294 ▶ if ($self->is_document($node)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_document($node)) { } 12 282 294
47 12 return $node
48 } else {
49 282 return $node->ownerDocument()
50 }
51 }
52  
53 0 ▶sub doc_URI {
Subroutine doc_URI: not called CC=1 SCAR=6.9
Pod undocumented
54 0 my ($class,$dom)=@_;
55 0 return $dom->URI();
56 }
57  
58 0 ▶sub doc_encoding {
Subroutine doc_encoding: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my ($class,$dom)=@_;
60 0 return $dom->getEncoding();
61 }
62  
63 0 ▶sub set_encoding {
Subroutine set_encoding: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my ($class,$dom,$encoding)=@_;
65 0 return $dom->setEncoding($encoding);
66 }
67  
68 224 ▶sub xml_equal {
Subroutine xml_equal: called CC=1 SCAR=0.0
Pod undocumented
69 224 my ($class,$a,$b)=@_;
70 224 return $a->isSameNode($b);
71 }
72  
73 0 ▶sub doc_process_xinclude {
Subroutine doc_process_xinclude: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my ($class,$parser,$doc)=@_;
75 0 $parser->processXIncludes($doc);
76 }
77  
78 54 ▶sub init_parser {
Subroutine init_parser: called CC=3 SCAR=11.1
Pod undocumented
79 54 my ($class,$parser)=@_;
80 54 $parser->validation(0+$XML::XSH2::Functions::VALIDATION);
81 54 ▶ $parser->recover(0+$XML::XSH2::Functions::RECOVERING) if $parser->can('recover');
Branch: 1 branch
BranchTrueFalseTotal
if $parser->can("recover") 54 0 54
82 54 $parser->expand_entities(0+$XML::XSH2::Functions::PARSER_EXPANDS_ENTITIES);
83 54 $parser->keep_blanks(0+$XML::XSH2::Functions::KEEP_BLANKS);
84 54 $parser->pedantic_parser(0+$XML::XSH2::Functions::PEDANTIC_PARSER);
85 54 $parser->load_ext_dtd(0+$XML::XSH2::Functions::LOAD_EXT_DTD);
86 54 $parser->complete_attributes(0+$XML::XSH2::Functions::PARSER_COMPLETES_ATTRIBUTES);
87 54 $parser->expand_xinclude(0+$XML::XSH2::Functions::PARSER_EXPANDS_XINCLUDE);
88 54 ▶ if ($parser->can('line_numbers')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parser->can("line_numbers")) 54 0 54
89 54 $parser->line_numbers(0+$XML::XSH2::Functions::LINE_NUMBERS);
90 }
91 }
92  
93 0 ▶sub load_catalog {
Subroutine load_catalog: not called CC=1 SCAR=6.9
Pod undocumented
94 0 my ($class,$parser,$catalog)=@_;
95 0 $parser->load_catalog($catalog);
96 }
97  
98 0 ▶sub parse_chunk {
Subroutine parse_chunk: not called CC=1 SCAR=6.9
Pod undocumented
99 0 my ($class,$parser,$str)=@_;
100 0 $class->init_parser($parser);
101 0 return $parser->parse_xml_chunk($str);
102 }
103  
104 53 ▶sub parse_string {
Subroutine parse_string: called CC=1 SCAR=0.0
Pod undocumented
105 53 my ($class,$parser,$str)=@_;
106 53 $class->init_parser($parser);
107 53 return $parser->parse_string($str);
108 }
109  
110 0 ▶sub parse_html_file {
Subroutine parse_html_file: not called CC=1 SCAR=6.9
Pod undocumented
111 0 my ($class,$parser,$file)=@_;
112 0 $class->init_parser($parser);
113 0 my $doc=$parser->parse_html_file($file);
114 0 return $doc;
115 }
116  
117 0 ▶sub parse_html_fh {
Subroutine parse_html_fh: not called CC=1 SCAR=6.9
Pod undocumented
118 0 my ($class,$parser,$fh)=@_;
119 0 $class->init_parser($parser);
120 0 my $doc=$parser->parse_html_fh($fh);
121 0 return $doc;
122 }
123  
124 0 ▶sub parse_html_string {
Subroutine parse_html_string: not called CC=1 SCAR=6.9
Pod undocumented
125 0 my ($class,$parser,$file)=@_;
126 0 $class->init_parser($parser);
127 0 my $doc=$parser->parse_html_string($file);
128 0 return $doc;
129 }
130  
131 0 ▶sub parse_sgml_file {
Subroutine parse_sgml_file: not called CC=1 SCAR=6.9
Pod undocumented
132 0 my ($class,$parser,$file,$encoding)=@_;
133 0 $class->init_parser($parser);
134 0 my $doc=$parser->parse_sgml_file($file,$encoding);
135 0 return $doc;
136 }
137  
138 0 ▶sub parse_sgml_fh {
Subroutine parse_sgml_fh: not called CC=1 SCAR=6.9
Pod undocumented
139 0 my ($class,$parser,$fh,$encoding)=@_;
140 0 $class->init_parser($parser);
141 0 my $doc=$parser->parse_sgml_fh($fh,$encoding);
142 0 return $doc;
143 }
144  
145 0 ▶sub parse_sgml_string {
Subroutine parse_sgml_string: not called CC=1 SCAR=6.9
Pod undocumented
146 0 my ($class,$parser,$fh,$encoding)=@_;
147 0 $class->init_parser($parser);
148 0 my $doc=$parser->parse_sgml_string($fh,$encoding);
149 0 return $doc;
150 }
151  
152 0 ▶sub parse_fh {
Subroutine parse_fh: not called CC=1 SCAR=6.9
Pod undocumented
153 0 my ($class,$parser,$fh)=@_;
154 0 $class->init_parser($parser);
155 0 return $parser->parse_fh($fh);
156 }
157  
158 1 ▶sub parse_file {
Subroutine parse_file: called CC=1 SCAR=0.0
Pod undocumented
159 1 my ($class,$parser,$file)=@_;
160 1 $class->init_parser($parser);
161 1 return $parser->parse_file($file);
162 }
163  
164 0 ▶sub is_node {
Subroutine is_node: not called CC=2 SCAR=17.9
Pod undocumented
165 0 my ($class,$node)=@_;
166 0 ▶ return ref($node) && $node->isa('XML::LibXML::Node');
Condition0%0/3
ref $node && $node->isa('XML::LibXML::Node')
!ll&&!rl&&r
000
MC/DC0%0/2
ref $node && $node->isa('XML::LibXML::Node')
ref $node $node->isa('XML::LibXML::Node')
Truth table0%0/3
A && B
A= ref $nodeB= $node->isa('XML::LibXML::Node')
ABresult
0X0
100
111
167 }
168  
169 0 ▶sub is_dtd {
Subroutine is_dtd: not called CC=1 SCAR=6.9
Pod undocumented
170 0 my ($class,$node)=@_;
171 0 return $node->nodeType == XML::LibXML::XML_DTD_NODE()
172 }
173  
174 0 ▶sub is_xinclude_start {
Subroutine is_xinclude_start: not called CC=1 SCAR=6.9
Pod undocumented
175 0 my ($class,$node)=@_;
176 0 return $node->nodeType == XML::LibXML::XML_XINCLUDE_START();
177 }
178  
179 0 ▶sub is_xinclude_end {
Subroutine is_xinclude_end: not called CC=1 SCAR=6.9
Pod undocumented
180 0 my ($class,$node)=@_;
181 0 return $node->nodeType == XML::LibXML::XML_XINCLUDE_END();
182 }
183  
184 524 ▶sub is_element {
Subroutine is_element: called CC=1 SCAR=0.0
Pod undocumented
185 524 my ($class,$node)=@_;
186 524 return $node->nodeType == XML::LibXML::XML_ELEMENT_NODE();
187 }
188  
189 590 ▶sub is_attribute {
Subroutine is_attribute: called CC=1 SCAR=0.0
Pod undocumented
190 590 my ($class,$node)=@_;
191 590 return $node->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE();
192 }
193  
194 93 ▶sub is_text {
Subroutine is_text: called CC=1 SCAR=0.0
Pod undocumented
195 93 my ($class,$node)=@_;
196 93 return $node->nodeType == XML::LibXML::XML_TEXT_NODE();
197 }
198  
199 0 ▶sub is_text_or_cdata {
Subroutine is_text_or_cdata: not called CC=2 SCAR=17.9
Pod undocumented
200 0 my ($class,$node)=@_;
201 0 ▶ return $node->nodeType == XML::LibXML::XML_TEXT_NODE() || $node->nodeType == XML::LibXML::XML_CDATA_SECTION_NODE();
Condition0%0/3
$node->nodeType == 3 || $node->nodeType == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->nodeType == 3 || $node->nodeType == 4
$node->nodeType == 3 $node->nodeType == 4
Truth table0%0/3
A || B
A= $node->nodeType == 3B= $node->nodeType == 4
ABresult
1X1
011
000
202 }
203  
204 54 ▶sub is_cdata_section {
Subroutine is_cdata_section: called CC=1 SCAR=0.0
Pod undocumented
205 54 my ($class,$node)=@_;
206 54 return $node->nodeType == XML::LibXML::XML_CDATA_SECTION_NODE();
207 }
208  
209  
210 49 ▶sub is_pi {
Subroutine is_pi: called CC=1 SCAR=0.0
Pod undocumented
211 49 my ($class,$node)=@_;
212 49 return $node->nodeType == XML::LibXML::XML_PI_NODE();
213 }
214  
215 18 ▶sub is_entity_reference {
Subroutine is_entity_reference: called CC=1 SCAR=0.0
Pod undocumented
216 18 my ($class,$node)=@_;
217 18 return $node->nodeType == XML::LibXML::XML_ENTITY_REF_NODE();
218 }
219  
220 710 ▶sub is_document {
Subroutine is_document: called CC=2 SCAR=7.1
Pod undocumented
221 710 my ($class,$node)=@_;
222 710 ▶ return $node->nodeType == XML::LibXML::XML_DOCUMENT_NODE() ||
Condition66%2/3
$node->nodeType == 9 || $node->nodeType == 13
l!l&&r!l&&!r
410669
MC/DC50%1/2
$node->nodeType == 9 || $node->nodeType == 13
$node->nodeType == 9 $node->nodeType == 13
Truth table66%2/3
A || B
A= $node->nodeType == 9B= $node->nodeType == 13
ABresult
1X1
011
000
223 $node->nodeType == XML::LibXML::XML_HTML_DOCUMENT_NODE();
224 }
225  
226 72 ▶sub is_document_fragment {
Subroutine is_document_fragment: called CC=1 SCAR=0.0
Pod undocumented
227 72 my ($class,$node)=@_;
228 72 return $node->nodeType == XML::LibXML::XML_DOCUMENT_FRAG_NODE();
229 }
230  
231 60 ▶sub is_comment {
Subroutine is_comment: called CC=1 SCAR=0.0
Pod undocumented
232 60 my ($class,$node)=@_;
233 60 return $node->nodeType == XML::LibXML::XML_COMMENT_NODE();
234 }
235  
236 34 ▶sub is_namespace {
Subroutine is_namespace: called CC=1 SCAR=0.0
Pod undocumented
237 34 my ($class,$node)=@_;
238 34 return $node->nodeType == XML::LibXML::XML_NAMESPACE_DECL();
239 }
240  
241 2 ▶sub document_type {
Subroutine document_type: called CC=3 SCAR=14.2
Pod undocumented
242 2 my ($class,$node)=@_;
243 2 my $doc=$class->owner_document($node);
244 2 ▶ if ($doc->nodeType == XML::LibXML::XML_DOCUMENT_NODE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($doc->nodeType == 9) { } 2 0 2
elsif ($doc->nodeType == 13) { } 0 0 0
245 2 return 'xml';
246 } elsif ($doc->nodeType == XML::LibXML::XML_HTML_DOCUMENT_NODE) {
247 0 return 'html';
248 } else {
249 0 return 'unknown';
250 }
251 }
252  
253 0 ▶sub has_dtd {
Subroutine has_dtd: not called CC=3 SCAR=24.8
Pod undocumented
254 0 my ($class,$doc)=@_;
255 0 foreach my $node ($doc->childNodes()) {
256 0 ▶ if ($node->nodeType == XML::LibXML::XML_DTD_NODE()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeType == 14) 0 0 0
257 0 return 1;
258 }
259 }
260 0 return 0;
261 }
262  
263 1 ▶sub get_dtd {
Subroutine get_dtd: called CC=12 SCAR=43.3
Pod undocumented
264 1 my ($class,$doc,$quiet)=@_;
265 1 my $dtd;
266 1 foreach my $node ($doc->childNodes()) {
267 2 ▶ if ($node->nodeType == XML::LibXML::XML_DTD_NODE()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeType == 14) 1 1 2
268 1 ▶ if ($node->hasChildNodes()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->hasChildNodes) { } 1 0 1
269 1 $dtd=$node;
270 } else {
271 0 my $str=$node->toString();
272 0 my $name=$node->getName();
273 0 my $public_id;
274 my $system_id;
275 0 ▶ if ($str=~/PUBLIC\s+(\S)([^\1]*\1)\s+(\S)([^\3]*)\3/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /PUBLIC\s+(\S)([^\1]*\1)\s+(\S)([^\3]*)\3/) 0 0 0
276 0 $public_id=$2;
277 0 $system_id=$4;
278 }
279 0 ▶ if ($str=~/SYSTEM\s+(\S)([^\1]*)\1/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /SYSTEM\s+(\S)([^\1]*)\1/) 0 0 0
280 0 $system_id=$2;
281 }
282 0 ▶ if ($system_id!~m(/)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($system_id =~ m[/]) 0 0 0
283 0 ▶ $system_id="$1$system_id" if ($class->doc_URI($doc)=~m(^(.*/)[^/]+$));
Branch: 1 branch
BranchTrueFalseTotal
if $class->doc_URI($doc) =~ m[^(.*/)[^/]+$] 0 0 0
284 }
285 0 ▶ print STDERR "loading external dtd: $system_id\n" unless $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 0 0
286 0 ▶ $dtd=XML::LibXML::Dtd->new($public_id, $system_id)
Branch: 1 branch
BranchTrueFalseTotal
if $system_id ne "" 0 0 0
287 if $system_id ne "";
288 0 ▶ if ($dtd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dtd) { } 0 0 0
289 0 $dtd->setName($name);
290 } else {
291 0 ▶ print STDERR "failed to load dtd: $system_id\n" unless $quiet;
Branch: 1 branch
BranchTrueFalseTotal
unless $quiet 0 0 0
292 }
293 }
294 }
295 }
296 1 return $dtd;
297 }
298  
299 72 ▶sub clone_node {
Subroutine clone_node: called CC=1 SCAR=0.0
Pod undocumented
300 72 my ($class, $dom, $node)=@_;
301 72 return $dom->importNode($node);
302 }
303  
304 39 ▶sub remove_node {
Subroutine remove_node: called CC=1 SCAR=0.0
Pod undocumented
305 39 my ($class,$node)=@_;
306 39 return $node->unbindNode();
307 }
308  
309 0 ▶sub iterator {
Subroutine iterator: not called CC=1 SCAR=6.9
Pod undocumented
310 0 my ($class,$node)=@_;
311 0 my $iter= XML::LibXML::SubTreeIterator->new( $node );
312 0 $iter->iterator_function(\&XML::LibXML::SubTreeIterator::subtree_iterator);
313 0 return $iter;
314 }
315  
316  
317 package # hide from PAUSE
318 XML::LibXML::SubTreeIterator;
319 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
320 8 ▶use base qw(XML::LibXML::Iterator);
Subroutine BEGIN: called CC=1 SCAR=0.0
321 # (inheritance is not a real necessity here)
322  
323 0 ▶sub subtree_iterator {
Subroutine subtree_iterator: not called CC=15 SCAR=54.8
324 0 my $self = shift;
325 0 my $dir = shift;
326 0 my $node = undef;
327  
328  
329 0 ▶ if ( $dir < 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dir < 0) { } 0 0 0
330 return undef if $self->{CURRENT}->isSameNode( $self->{FIRST} )
331 0 ▶ and $self->{INDEX} <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CURRENT"}->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} <= 0 0 0 0
Condition0%0/3
$self->{"CURRENT"}->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} <= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CURRENT"}->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} <= 0
$self->{"CURRENT"}->isSameNode($self->{"FIRST"}) $self->{"INDEX"} <= 0
Truth table0%0/3
A and B
A= $self->{"CURRENT"}->isSameNode($self->{"FIRST"})B= $self->{"INDEX"} <= 0
ABresult
0X0
100
111
332  
333 0 $node = $self->{CURRENT}->previousSibling;
334 0 ▶ return $self->{CURRENT}->parentNode unless defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 0 0
335  
336 0 ▶ while ( $node->hasChildNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->hasChildNodes) 0 0 0
337 return undef if $node->isSameNode( $self->{FIRST} )
338 0 ▶ and $self->{INDEX} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $node->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} > 0 0 0 0
Condition0%0/3
$node->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$node->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} > 0
$node->isSameNode($self->{"FIRST"}) $self->{"INDEX"} > 0
Truth table0%0/3
A and B
A= $node->isSameNode($self->{"FIRST"})B= $self->{"INDEX"} > 0
ABresult
0X0
100
111
339 0 $node = $node->lastChild;
340 }
341 }
342 else {
343 return undef if $self->{CURRENT}->isSameNode( $self->{FIRST} )
344 0 ▶ and $self->{INDEX} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"CURRENT"}->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} > 0 0 0 0
Condition0%0/3
$self->{"CURRENT"}->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"CURRENT"}->isSameNode($self->{"FIRST"}) and $self->{"INDEX"} > 0
$self->{"CURRENT"}->isSameNode($self->{"FIRST"}) $self->{"INDEX"} > 0
Truth table0%0/3
A and B
A= $self->{"CURRENT"}->isSameNode($self->{"FIRST"})B= $self->{"INDEX"} > 0
ABresult
0X0
100
111
345  
346 0 ▶ if ( $self->{CURRENT}->hasChildNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'CURRENT'}->hasChildNodes) { } 0 0 0
347 0 $node = $self->{CURRENT}->firstChild;
348 }
349 else {
350 0 $node = $self->{CURRENT}->nextSibling;
351 0 my $pnode = $self->{CURRENT}->parentNode;
352 0 ▶ while ( not defined $node ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $node) 0 0 0
353 0 ▶ last unless defined $pnode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pnode 0 0 0
354 0 ▶ return undef if $pnode->isSameNode( $self->{FIRST} );
Branch: 1 branch
BranchTrueFalseTotal
if $pnode->isSameNode($self->{"FIRST"}) 0 0 0
355 0 $node = $pnode->nextSibling;
356 0 ▶ $pnode = $pnode->parentNode unless defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 0 0
357 }
358 }
359 }
360  
361 0 return $node;
362 }
363  
364 {
365 8 local $^W=0;
366 0 ▶ eval <<'EOF';
Subroutine BEGIN: called CC=1 SCAR=4.2
Subroutine BEGIN: called CC=1 SCAR=4.2
Subroutine BEGIN: called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=1 SCAR=4.2
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine __ANON__: not called CC=3 SCAR=20.3
Subroutine add: called CC=4 SCAR=25.0
Subroutine new: called CC=2 SCAR=14.0
Subroutine parentNode: not called CC=1 SCAR=4.2
Subroutine subtract: not called CC=3 SCAR=20.3
Subroutine value: called CC=1 SCAR=4.2
Pod undocumented
Pod documented
Pod undocumented
Pod undocumented
Branch: 15 branches
BranchTrueFalseTotal
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
defined $_[2] && $_[2] ? : 0 0 0
if (UNIVERSAL::isa($_[1], 'XML::LibXML::NodeList')) { } 2 0 2
if (defined $_[2]) { } 0 2 2
$_[2] ? : 0 0 0
if (not $number =~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) { } 0 160 160
if (UNIVERSAL::isa($_[1], 'XML::LibXML::NodeList')) { } 0 0 0
$_[2] ? : 0 0 0
Condition0%0/27
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
defined $_[2] and $_[2]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
MC/DC0%0/2
defined $_[2] and $_[2]
defined $_[2] $_[2]
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $_[2]B= $_[2]
ABresult
0X0
100
111
367 package # hide from PAUSE
368 XML::LibXML::Namespace;
369 sub parentNode {}
370  
371 package # hide from PAUSE
372 XML::LibXML::NodeList;
373  
374 use overload
375 '""' => \&value,
376 '0+' => \&value,
377 '+' => \&add,
378 '-' => \&subtract,
379 'bool' => \&to_boolean,
380 'fallback' => undef;
381  
382 sub add {
383 if (UNIVERSAL::isa($_[1],'XML::LibXML::NodeList')) {
384 if (defined($_[2])) {
385 $_[2] ? XML::LibXML::NodeList->new(@{$_[1]},@{$_[0]}) :
386 XML::LibXML::NodeList->new(@{$_[0]},@{$_[1]});
387 } else {
388 $_[0]->append($_[1]);
389 $_[0]
390 }
391 } else {
392 $_[0]->value + $_[1]
393 }
394 }
395  
396 sub subtract {
397 if (UNIVERSAL::isa($_[1],'XML::LibXML::NodeList')) {
398 my ($plus,$minus);
399 ($plus,$minus)= $_[2] ? ($_[1],$_[0]) : ($_[0],$_[1]);
400 my %minus; @minus{ map $$_,@$minus } = ();
401 return XML::LibXML::NodeList->new(grep !exists($minus{$$_}),@$plus);
402 } else {
403 $_[0]->value - $_[1]
404 }
405 }
406  
407 sub value {
408 my $self = CORE::shift;
409 my $result = join('', grep {defined $_} map { $_->string_value } @$self);
410 return $result;
411 }
412  
413 package # hide from PAUSE
414 XML::LibXML::Literal;
415 use overload
416 '""' => \&value,
417 '0+' => \&value,
418 'cmp' => \&cmp,
419 '<=>' => sub { defined($_[2]) && $_[2] ? ($_[1] <=> ${$_[0]}) : (${$_[0]} <=> $_[1]) },
420 '+' => sub { ${$_[0]}+$_[1] },
421 '-' => sub { defined($_[2]) && $_[2] ? $_[1]-${$_[0]} : ${$_[0]}-$_[1] },
422 '*' => sub { ${$_[0]}*$_[1] },
423 '**' => sub { ${$_[0]}**$_[1] },
424 '/' => sub { ${$_[0]}/$_[1] },
425 '%' => sub { ${$_[0]}%$_[1] },
426 'x' => sub { defined($_[2]) && $_[2] ? $_[1] x ${$_[0]} : ${$_[0]} x $_[1] },
427 'fallback' => undef;
428  
429  
430 package # hide form PAUSE
431 XML::LibXML::Number;
432  
433 use overload
434 '""' => \&value,
435 '0+' => \&value,
436 '<=>' => \&cmp,
437 'cmp' => sub { defined($_[2]) && $_[2] ? ($_[1] cmp ${$_[0]}) : (${$_[0]} cmp $_[1]) },
438 '+' => sub { ${$_[0]}+$_[1] },
439 '-' => sub { defined($_[2]) && $_[2] ? $_[1]-${$_[0]} : ${$_[0]}-$_[1] },
440 '*' => sub { ${$_[0]}*$_[1] },
441 '**' => sub { defined($_[2]) && $_[2] ? $_[1]**${$_[0]} : ${$_[0]}**$_[1] },
442 '/' => sub { defined($_[2]) && $_[2] ? $_[1]/${$_[0]} : ${$_[0]}/$_[1] },
443 '%' => sub { defined($_[2]) && $_[2] ? $_[1] % ${$_[0]} : ${$_[0]} % $_[1] },
444 'x' => sub { defined($_[2]) && $_[2] ? $_[1] x ${$_[0]} : ${$_[0]} x $_[1] },
445 'fallback' => undef;
446  
447 sub new {
448 my $class = shift;
449 my $number = shift;
450 if ($number !~ /^\s*(-\s*)?(\d+(\.\d*)?|\.\d+)\s*$/) {
451 $number = undef;
452 }
453 else {
454 $number =~ s/\s*//g;
455 }
456 bless \$number, $class;
457 }
458  
459 EOF
460 8 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 8 8
461 };
462  
463  
464  
465 8 1;
466  
467  
« XSH2/XPathToXML.pm ↑ Summary XSH2/Iterators.pm »