blib/lib/Zuzu/Module/XML.pm

filter: Statementstmt 33.1% 143 / 431 Branchbran 8.4% 13 / 154 Conditioncond 26.9% 7 / 26 MC/DCmcdc 6.2% 1 / 16 Subroutinesub 21.6% 18 / 83 Podpod 0.0% 0 / 1 totaltotal 25.6% 182 / 711 CC 95 SCAR 25.9
CC
95
Cov
27%
_visit_tree
72.0
_node_class_for
30.0
_truthy
30.0
CRAP 13.4
« blib/lib/Zuzu/Module/JSON.pm ↑ Summary blib/lib/Zuzu/Value/PairList.pm »
1 package Zuzu::Module::XML;
2  
3 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 our $VERSION = '0.007002';
6  
7 4 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Encode qw( decode encode FB_CROAK );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use HTML::Selector::XPath ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use XML::LibXML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Zuzu::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 4 ▶use Zuzu::Util::NativeHelpers qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
14 native_class
15 native_function
16 native_object
17 perl_to_zuzu
18 4 );
19  
20 2 ▶sub _is_zuzu_object {
Subroutine _is_zuzu_object: called CC=1 SCAR=0.0
21 2 my ( $value ) = @_;
22  
23 2 return blessed($value)
24 and $value->isa('Zuzu::Value::Object');
25 }
26  
27 3 ▶sub _xml_text {
Subroutine _xml_text: called CC=5 SCAR=19.6
28 3 my ( $value ) = @_;
29 3 ▶ $value = defined $value ? "$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 3 0 3
30 3 ▶ $value = decode( 'UTF-8', $value ) if not utf8::is_utf8($value);
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::is_utf8($value) 2 1 3
31 3 ▶ if ( $value =~ /[\x{00c2}-\x{00f4}][\x{0080}-\x{00bf}]/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /[\x{00c2}-\x{00f4}][\x{0080}-\x{00bf}]/) 0 3 3
32 0 my $decoded = eval {
33 0 decode( 'UTF-8', encode( 'ISO-8859-1', $value, FB_CROAK ), FB_CROAK );
34 };
35 0 ▶ return $decoded if defined $decoded;
Branch: 1 branch
BranchTrueFalseTotal
if defined $decoded 0 0 0
36 }
37 3 return $value;
38 }
39  
40 0 ▶sub _xml_maybe_text {
Subroutine _xml_maybe_text: not called CC=2 SCAR=17.9
41 0 my ( $value ) = @_;
42 0 ▶ return undef if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
43 0 return _xml_text($value);
44 }
45  
46 0 ▶sub _unwrap_node {
Subroutine _unwrap_node: not called CC=3 SCAR=24.8
47 0 my ( $value ) = @_;
48  
49 0 ▶ die "expected XMLNode object" if not _is_zuzu_object( $value );
Branch: 1 branch
BranchTrueFalseTotal
unless _is_zuzu_object($value) 0 0 0
50 0 ▶ die "expected XMLNode object" if not exists $value->slots->{_node};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $value->slots->{"_node"} 0 0 0
51  
52 0 return $value->slots->{_node};
53 }
54  
55 1 ▶sub _unwrap_doc {
Subroutine _unwrap_doc: called CC=3 SCAR=11.4
56 1 my ( $value ) = @_;
57  
58 1 ▶ die "expected XMLDocument object" if not _is_zuzu_object( $value );
Branch: 1 branch
BranchTrueFalseTotal
unless _is_zuzu_object($value) 0 1 1
59 1 ▶ die "expected XMLDocument object" if not exists $value->slots->{_doc};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $value->slots->{"_doc"} 0 1 1
60  
61 1 return $value->slots->{_doc};
62 }
63  
64 4 ▶sub _unwrap_path_tiny {
Subroutine _unwrap_path_tiny: called CC=7 SCAR=21.8
65 4 my ( $path_obj, $label ) = @_;
66 4 ▶ $label //= 'XML';
Condition50%1/2
$label //= "XML"
l!l
40
MC/DC0%0/1
$label //= "XML"
$label
Truth table50%1/2
A
A= $label
Aresult
11
00
67  
68 4 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($path_obj) and $path_obj->isa('Zuzu::Value::Object') and exists $path_obj->slots->{'_path_tiny'}) { } 2 2 4
elsif (ref $path_obj eq 'HASH' and exists $path_obj->{'_path_tiny'}) { } 0 4 4
Condition66%4/6
builtin::blessed($path_obj) and $path_obj->isa("Zuzu::Value::Object") and exists $path_obj->slots->{"_path_tiny"}
!ll&&!rl&&r
202
builtin::blessed($path_obj) and $path_obj->isa("Zuzu::Value::Object")
!ll&&!rl&&r
202
MC/DC33%1/3
builtin::blessed($path_obj) and $path_obj->isa("Zuzu::Value::Object") and exists $path_obj->slots->{"_path_tiny"}
builtin::blessed($path_obj) $path_obj->isa("Zuzu::Value::Object") exists $path_obj->slots->{"_path_tiny"}
Truth table50%2/4
A and B and C
A= builtin::blessed($path_obj)B= $path_obj->isa("Zuzu::Value::Object")C= exists $path_obj->slots->{"_path_tiny"}
ABCresult
0XX0
10X0
1100
1111
69 blessed($path_obj)
70 and $path_obj->isa('Zuzu::Value::Object')
71 and exists $path_obj->slots->{_path_tiny}
72 ) {
73 2 return $path_obj->slots->{_path_tiny};
74 }
75 ▶ elsif ( ref($path_obj) eq 'HASH' and exists $path_obj->{_path_tiny} ) {
Condition33%1/3
ref $path_obj eq "HASH" and exists $path_obj->{"_path_tiny"}
!ll&&!rl&&r
200
MC/DC0%0/2
ref $path_obj eq "HASH" and exists $path_obj->{"_path_tiny"}
ref $path_obj eq "HASH" exists $path_obj->{"_path_tiny"}
Truth table33%1/3
A and B
A= ref $path_obj eq "HASH"B= exists $path_obj->{"_path_tiny"}
ABresult
0X0
100
111
76 0 return $path_obj->{_path_tiny};
77 }
78  
79 2 die Zuzu::Error->new_runtime(
80 message => "TypeException: $label expects Path as first argument",
81 file => '<std/data/xml>',
82 line => 0,
83 );
84 }
85  
86 0 ▶sub _wrap_node {
Subroutine _wrap_node: not called CC=2 SCAR=17.9
87 0 my ( $classes, $node ) = @_;
88  
89 0 ▶ return undef if not defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 0 0
90 0 my $node_class = _node_class_for( $classes, $node );
91  
92 0 return native_object(
93 class => $node_class,
94 slots => {
95 _node => $node,
96 },
97 const => {
98 _node => 1,
99 },
100 );
101 }
102  
103 3 ▶sub _wrap_doc {
Subroutine _wrap_doc: called CC=2 SCAR=7.1
104 3 my ( $doc_class, $doc ) = @_;
105  
106 3 ▶ return undef if not defined $doc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $doc 0 3 3
107  
108 3 return native_object(
109 class => $doc_class,
110 slots => {
111 _doc => $doc,
112 },
113 const => {
114 _doc => 1,
115 },
116 );
117 }
118  
119 1 ▶sub _bool {
Subroutine _bool: called CC=2 SCAR=7.2
120 1 my ( $value ) = @_;
121  
122 1 ▶ return $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 1 1
123 }
124  
125 0 ▶sub _node_list_to_zuzu {
Subroutine _node_list_to_zuzu: not called CC=1 SCAR=6.9
126 0 my ( $classes, @nodes ) = @_;
127  
128 my @wrapped = map {
129 0 _wrap_node( $classes, $_ )
130 } @nodes;
131  
132 0 return perl_to_zuzu( \@wrapped );
133 }
134  
135 0 ▶sub _selector_to_xpath {
Subroutine _selector_to_xpath: not called CC=2 SCAR=17.9
136 0 my ( $selector ) = @_;
137  
138 0 ▶ $selector = defined $selector ? "$selector" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $selector ? : 0 0 0
139 0 my $xpath = HTML::Selector::XPath::selector_to_xpath( $selector );
140 0 $xpath =~ s{(^|\|)\s*//}{$1.//}g;
141 0 return $xpath;
142 }
143  
144 0 ▶sub _node_class_for {
Subroutine _node_class_for: not called CC=5 SCAR=34.0
145 0 my ( $classes, $node ) = @_;
146  
147 return $classes->{DOMElement}
148 0 ▶ if $node->isa('XML::LibXML::Element');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("XML::LibXML::Element") 0 0 0
149 return $classes->{DOMComment}
150 0 ▶ if $node->isa('XML::LibXML::Comment');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("XML::LibXML::Comment") 0 0 0
151 return $classes->{DOMText}
152 0 ▶ if $node->isa('XML::LibXML::Text');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("XML::LibXML::Text") 0 0 0
153 return $classes->{DOMDocument}
154 0 ▶ if $node->isa('XML::LibXML::Document');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("XML::LibXML::Document") 0 0 0
155 0 return $classes->{DOMNode};
156 }
157  
158 0 ▶sub _doc_from_node {
Subroutine _doc_from_node: not called CC=3 SCAR=24.8
159 0 my ( $node ) = @_;
160  
161 0 ▶ return undef if not defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 0 0
162 0 ▶ return $node if $node->isa('XML::LibXML::Document');
Branch: 1 branch
BranchTrueFalseTotal
if $node->isa("XML::LibXML::Document") 0 0 0
163 0 return $node->ownerDocument;
164 }
165  
166 0 ▶sub _is_function {
Subroutine _is_function: not called CC=1 SCAR=6.9
167 0 my ( $value ) = @_;
168  
169 0 return blessed($value)
170 and $value->isa('Zuzu::Value::Function');
171 }
172  
173 0 ▶sub _truthy {
Subroutine _truthy: not called CC=5 SCAR=34.0
174 0 my ( $value ) = @_;
175  
176 0 ▶ return 0 if not defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
177 0 ▶ return $value->is_truthy if blessed($value) and $value->can('is_truthy');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->can("is_truthy") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->can("is_truthy")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->can("is_truthy")
builtin::blessed($value) $value->can("is_truthy")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->can("is_truthy")
ABresult
0X0
100
111
178 0 ▶ return $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
179 }
180  
181 0 ▶sub _visit_tree {
Subroutine _visit_tree: not called CC=8 SCAR=42.8
182 0 my ( $classes, $runtime, $start_node, $visitor, $stop_on_match, $include_root ) = @_;
183  
184 0 ▶ die "expected function argument" if not _is_function( $visitor );
Branch: 1 branch
BranchTrueFalseTotal
unless _is_function($visitor) 0 0 0
185  
186 0 my @stack;
187 0 ▶ if ($include_root) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_root) { } 0 0 0
188 0 @stack = ( [ $start_node, 0 ] );
189 }
190 else {
191 0 my @children = $start_node->childNodes;
192 0 @stack = map { [ $_, 1 ] } reverse @children;
193 }
194 0 ▶ while ( @stack ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@stack) 0 0 0
195 0 my ( $node, $depth ) = @{ pop @stack };
196 0 my $wrapped = _wrap_node( $classes, $node );
197 0 my $result = $runtime->_call_function( $visitor, [ $wrapped ], '<std/data/xml>', 0 );
198 0 ▶ if ( $stop_on_match and _truthy($result) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stop_on_match and _truthy($result)) 0 0 0
Condition0%0/3
$stop_on_match and _truthy($result)
!ll&&!rl&&r
000
MC/DC0%0/2
$stop_on_match and _truthy($result)
$stop_on_match _truthy($result)
Truth table0%0/3
A and B
A= $stop_on_matchB= _truthy($result)
ABresult
0X0
100
111
199 0 return $wrapped;
200 }
201 0 my @children = $node->childNodes;
202 0 for my $child ( reverse @children ) {
203 0 push @stack, [ $child, $depth + 1 ];
204 }
205 }
206  
207 0 ▶ return undef if $stop_on_match;
Branch: 1 branch
BranchTrueFalseTotal
if $stop_on_match 0 0 0
208 0 return 1;
209 }
210  
211 14 ▶sub IMPORT {
Subroutine IMPORT: called CC=7 SCAR=33.6
Pod undocumented
212 14 my ( $class, $runtime ) = @_;
213  
214 14 my $xml_class = native_class(
215 name => 'XML',
216 );
217 14 my $doc_class = native_class(
218 name => 'XMLDocument',
219 );
220 14 my $node_class = native_class(
221 name => 'XMLNode',
222 );
223 14 my $dom_node_class = native_class(
224 name => 'DOMNode',
225 parent => $node_class,
226 );
227 14 my $dom_doc_class = native_class(
228 name => 'DOMDocument',
229 parent => $dom_node_class,
230 );
231 14 my $dom_element_class = native_class(
232 name => 'DOMElement',
233 parent => $dom_node_class,
234 );
235 14 my $dom_comment_class = native_class(
236 name => 'DOMComment',
237 parent => $dom_node_class,
238 );
239 14 my $dom_text_class = native_class(
240 name => 'DOMText',
241 parent => $dom_node_class,
242 );
243 14 my $node_classes = {
244 DOMNode => $dom_node_class,
245 DOMDocument => $dom_doc_class,
246 DOMElement => $dom_element_class,
247 DOMComment => $dom_comment_class,
248 DOMText => $dom_text_class,
249 };
250  
251 $xml_class->static_methods->{parse} = native_function(
252 name => 'parse',
253 2 ▶ native => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
254 2 my ( $self, $xml_text ) = @_;
255 2 $xml_text = _xml_text($xml_text);
256  
257 2 my $parser = XML::LibXML->new();
258 2 my $doc = $parser->parse_string( $xml_text );
259 2 return _wrap_doc( $doc_class, $doc );
260 },
261 14 );
262  
263 $xml_class->static_methods->{load} = native_function(
264 name => 'load',
265 2 ▶ native => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
266 2 my ( $self, $path_obj ) = @_;
267 2 $runtime->assert_capability( 'fs', "XML.load is denied by runtime policy" );
268 2 my $path_tiny = _unwrap_path_tiny( $path_obj, 'XML.load' );
269 1 my $xml_text = _xml_text($path_tiny->slurp_utf8);
270  
271 1 my $parser = XML::LibXML->new();
272 1 my $doc = $parser->parse_string( $xml_text );
273 1 return _wrap_doc( $doc_class, $doc );
274 },
275 14 );
276  
277 $xml_class->static_methods->{dump} = native_function(
278 name => 'dump',
279 2 ▶ native => sub {
Subroutine __ANON__: called CC=5 SCAR=20.9
280 2 my ( $self, $path_obj, $value, $pretty ) = @_;
281 2 $runtime->assert_capability( 'fs', "XML.dump is denied by runtime policy" );
282 2 my $path_tiny = _unwrap_path_tiny( $path_obj, 'XML.dump' );
283 1 my $xml_text;
284  
285 1 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (_is_zuzu_object($value) and exists $value->slots->{'_doc'}) { } 1 0 1
elsif (_is_zuzu_object($value) and exists $value->slots->{'_node'}) { } 0 0 0
Condition33%1/3
_is_zuzu_object($value) and exists $value->slots->{"_doc"}
!ll&&!rl&&r
001
MC/DC0%0/2
_is_zuzu_object($value) and exists $value->slots->{"_doc"}
_is_zuzu_object($value) exists $value->slots->{"_doc"}
Truth table33%1/3
A and B
A= _is_zuzu_object($value)B= exists $value->slots->{"_doc"}
ABresult
0X0
100
111
286 _is_zuzu_object( $value )
287 and exists $value->slots->{_doc}
288 ) {
289 1 $xml_text = $value->slots->{_doc}->toString( _bool( $pretty ) );
290 }
291 ▶ elsif (
Condition0%0/3
_is_zuzu_object($value) and exists $value->slots->{"_node"}
!ll&&!rl&&r
000
MC/DC0%0/2
_is_zuzu_object($value) and exists $value->slots->{"_node"}
_is_zuzu_object($value) exists $value->slots->{"_node"}
Truth table0%0/3
A and B
A= _is_zuzu_object($value)B= exists $value->slots->{"_node"}
ABresult
0X0
100
111
292 _is_zuzu_object( $value )
293 and exists $value->slots->{_node}
294 ) {
295 0 $xml_text = $value->slots->{_node}->toString( _bool( $pretty ) );
296 }
297 else {
298 0 die "XML.dump expects an XMLDocument or XMLNode";
299 }
300  
301 1 $path_tiny->spew_utf8( $xml_text );
302 1 return $path_obj;
303 },
304 14 );
305  
306 $doc_class->methods->{documentElement} = native_function(
307 name => 'documentElement',
308 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
309 0 my ( $self ) = @_;
310 0 return _wrap_node( $node_classes, _unwrap_doc( $self )->documentElement );
311 },
312 14 );
313  
314 $doc_class->methods->{createElement} = native_function(
315 name => 'createElement',
316 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
317 0 my ( $self, $name ) = @_;
318 0 ▶ $name = defined $name ? "$name" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
319 0 my $node = _unwrap_doc( $self )->createElement( $name );
320 0 return _wrap_node( $node_classes, $node );
321 },
322 14 );
323  
324 $doc_class->methods->{createTextNode} = native_function(
325 name => 'createTextNode',
326 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
327 0 my ( $self, $text ) = @_;
328 0 ▶ $text = defined $text ? "$text" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $text ? : 0 0 0
329 0 my $node = _unwrap_doc( $self )->createTextNode( $text );
330 0 return _wrap_node( $node_classes, $node );
331 },
332 14 );
333  
334 $doc_class->methods->{createComment} = native_function(
335 name => 'createComment',
336 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
337 0 my ( $self, $text ) = @_;
338 0 ▶ $text = defined $text ? "$text" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $text ? : 0 0 0
339 0 my $node = _unwrap_doc( $self )->createComment( $text );
340 0 return _wrap_node( $node_classes, $node );
341 },
342 14 );
343  
344 $doc_class->methods->{createCDATASection} = native_function(
345 name => 'createCDATASection',
346 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
347 0 my ( $self, $text ) = @_;
348 0 ▶ $text = defined $text ? "$text" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $text ? : 0 0 0
349 0 my $node = _unwrap_doc( $self )->createCDATASection( $text );
350 0 return _wrap_node( $node_classes, $node );
351 },
352 14 );
353  
354 $doc_class->methods->{findnodes} = native_function(
355 name => 'findnodes',
356 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
357 0 my ( $self, $xpath ) = @_;
358 0 ▶ $xpath = defined $xpath ? "$xpath" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $xpath ? : 0 0 0
359 0 my @nodes = _unwrap_doc( $self )->findnodes( $xpath );
360 0 return _node_list_to_zuzu( $node_classes, @nodes );
361 },
362 14 );
363  
364 $doc_class->methods->{getElementsByTagName} = native_function(
365 name => 'getElementsByTagName',
366 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
367 0 my ( $self, $name ) = @_;
368 0 ▶ $name = defined $name ? "$name" : '*';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
369 0 my @nodes = _unwrap_doc( $self )->getElementsByTagName( $name );
370 0 return _node_list_to_zuzu( $node_classes, @nodes );
371 },
372 14 );
373  
374 $doc_class->methods->{getElementById} = native_function(
375 name => 'getElementById',
376 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
377 0 my ( $self, $id ) = @_;
378 0 ▶ $id = defined $id ? "$id" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $id ? : 0 0 0
379 0 my $node = _unwrap_doc( $self )->getElementById( $id );
380 0 return _wrap_node( $node_classes, $node );
381 },
382 14 );
383  
384 $doc_class->methods->{findvalue} = native_function(
385 name => 'findvalue',
386 1 ▶ native => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
387 1 my ( $self, $xpath ) = @_;
388 1 ▶ $xpath = defined $xpath ? "$xpath" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $xpath ? : 1 0 1
389 1 return "" . _unwrap_doc( $self )->findvalue( $xpath );
390 },
391 14 );
392  
393 14 for my $name ( qw( querySelectorAll querySelector ) ) {
394 $doc_class->methods->{$name} = native_function(
395 name => $name,
396 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
397 0 my ( $self, $selector ) = @_;
398 0 my $xpath = _selector_to_xpath( $selector );
399 0 my @nodes = _unwrap_doc( $self )->findnodes( $xpath );
400 0 ▶ return _node_list_to_zuzu( $node_classes, @nodes )
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "querySelectorAll" 0 0 0
401 if $name eq 'querySelectorAll';
402 0 return _wrap_node( $node_classes, $nodes[0] );
403 },
404 28 );
405 }
406  
407 $doc_class->methods->{toXML} = native_function(
408 name => 'toXML',
409 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
410 0 my ( $self, $pretty ) = @_;
411 0 return _xml_text( _unwrap_doc( $self )->toString( _bool( $pretty ) ) );
412 },
413 14 );
414  
415 $doc_class->methods->{to_String} = native_function(
416 name => 'to_String',
417 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
418 0 my ( $self ) = @_;
419 0 return _xml_text( _unwrap_doc( $self )->toString(0) );
420 },
421 14 );
422  
423 $doc_class->methods->{visitEach} = native_function(
424 name => 'visitEach',
425 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
426 0 my ( $self, $visitor ) = @_;
427 0 _visit_tree( $node_classes, $runtime, _unwrap_doc( $self ), $visitor, 0, 1 );
428 0 return $self;
429 },
430 14 );
431  
432 $doc_class->methods->{findFirst} = native_function(
433 name => 'findFirst',
434 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
435 0 my ( $self, $matcher ) = @_;
436 0 return _visit_tree( $node_classes, $runtime, _unwrap_doc( $self ), $matcher, 1, 0 );
437 },
438 14 );
439  
440 14 for my $name ( qw( nodeName nodeType nodeValue textContent ) ) {
441 $node_class->methods->{$name} = native_function(
442 name => $name,
443 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
444 0 my ( $self ) = @_;
445 0 my $value = _unwrap_node( $self )->$name();
446 0 return _xml_maybe_text($value);
447 },
448 56 );
449 }
450  
451 $node_class->methods->{uniqueKey} = native_function(
452 name => 'uniqueKey',
453 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
454 0 my ( $self ) = @_;
455 0 my $node = _unwrap_node( $self );
456 0 ▶ my $value = $node->can('unique_key')
Branch: 1 branch
BranchTrueFalseTotal
$node->can('unique_key') ? : 0 0 0
457 ? $node->unique_key()
458 : undef;
459 0 ▶ return defined $value ? "$value" : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
460 },
461 14 );
462  
463 $node_class->methods->{unique_id} = native_function(
464 name => 'unique_id',
465 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
466 0 my ( $self ) = @_;
467 0 my $node = _unwrap_node( $self );
468 0 ▶ my $value = $node->can('unique_key')
Branch: 1 branch
BranchTrueFalseTotal
$node->can('unique_key') ? : 0 0 0
469 ? $node->unique_key()
470 : undef;
471 0 ▶ return defined $value ? "$value" : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
472 },
473 14 );
474  
475 $node_class->methods->{localName} = native_function(
476 name => 'localName',
477 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
478 0 my ( $self ) = @_;
479 0 my $node = _unwrap_node( $self );
480 0 my $value;
481 0 ▶ if ( $node->can('localName') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->can('localName')) { } 0 0 0
elsif ($node->can('localname')) { } 0 0 0
482 0 $value = $node->localName();
483 }
484 elsif ( $node->can('localname') ) {
485 0 $value = $node->localname();
486 }
487 0 return _xml_maybe_text($value);
488 },
489 14 );
490  
491 $node_class->methods->{namespaceURI} = native_function(
492 name => 'namespaceURI',
493 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
494 0 my ( $self ) = @_;
495 0 my $node = _unwrap_node( $self );
496 0 ▶ return undef if not $node->can('namespaceURI');
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("namespaceURI") 0 0 0
497 0 my $value = $node->namespaceURI();
498 0 return _xml_maybe_text($value);
499 },
500 14 );
501  
502 $node_class->methods->{nodeKind} = native_function(
503 name => 'nodeKind',
504 0 ▶ native => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
505 0 my ( $self ) = @_;
506 0 my $type = _unwrap_node( $self )->nodeType;
507 0 ▶ return 'element' if $type == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $type == 1 0 0 0
508 0 ▶ return 'text' if $type == 3;
Branch: 1 branch
BranchTrueFalseTotal
if $type == 3 0 0 0
509 0 ▶ return 'comment' if $type == 8;
Branch: 1 branch
BranchTrueFalseTotal
if $type == 8 0 0 0
510 0 ▶ return 'document' if $type == 9;
Branch: 1 branch
BranchTrueFalseTotal
if $type == 9 0 0 0
511 0 return 'other';
512 },
513 14 );
514  
515 $node_class->methods->{setNodeValue} = native_function(
516 name => 'setNodeValue',
517 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
518 0 my ( $self, $value ) = @_;
519 0 ▶ $value = defined $value ? "$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
520 0 _unwrap_node( $self )->setNodeValue( $value );
521 0 return $self;
522 },
523 14 );
524  
525 $node_class->methods->{setTextContent} = native_function(
526 name => 'setTextContent',
527 0 ▶ native => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
528 0 my ( $self, $value ) = @_;
529 0 ▶ $value = defined $value ? "$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
530 0 my $node = _unwrap_node( $self );
531 0 ▶ if ( $node->can('setTextContent') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->can('setTextContent')) { } 0 0 0
elsif ($node->can('removeChildNodes') and $node->can('appendText')) { } 0 0 0
532 0 $node->setTextContent( $value );
533 }
534 ▶ elsif ( $node->can('removeChildNodes') and $node->can('appendText') ) {
Condition0%0/3
$node->can("removeChildNodes") and $node->can("appendText")
!ll&&!rl&&r
000
MC/DC0%0/2
$node->can("removeChildNodes") and $node->can("appendText")
$node->can("removeChildNodes") $node->can("appendText")
Truth table0%0/3
A and B
A= $node->can("removeChildNodes")B= $node->can("appendText")
ABresult
0X0
100
111
535 0 $node->removeChildNodes();
536 0 $node->appendText( $value );
537 }
538 else {
539 0 die "setTextContent not supported by this node type";
540 }
541 0 return $self;
542 },
543 14 );
544  
545 14 for my $name ( qw( firstChild lastChild nextSibling previousSibling parentNode ) ) {
546 $node_class->methods->{$name} = native_function(
547 name => $name,
548 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
549 0 my ( $self ) = @_;
550 0 return _wrap_node( $node_classes, _unwrap_node( $self )->$name() );
551 },
552 70 );
553 }
554  
555 $node_class->methods->{ownerDocument} = native_function(
556 name => 'ownerDocument',
557 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
558 0 my ( $self ) = @_;
559 0 my $doc = _doc_from_node( _unwrap_node( $self ) );
560 0 return _wrap_doc( $doc_class, $doc );
561 },
562 14 );
563  
564 $node_class->methods->{childNodes} = native_function(
565 name => 'childNodes',
566 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
567 0 my ( $self ) = @_;
568 0 my @children = _unwrap_node( $self )->childNodes();
569 0 return _node_list_to_zuzu( $node_classes, @children );
570 },
571 14 );
572  
573 $node_class->methods->{children} = native_function(
574 name => 'children',
575 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
576 0 my ( $self ) = @_;
577 0 my @children = grep { $_->nodeType == 1 } _unwrap_node( $self )->childNodes();
578 0 return _node_list_to_zuzu( $node_classes, @children );
579 },
580 14 );
581  
582 $node_class->methods->{hasChildNodes} = native_function(
583 name => 'hasChildNodes',
584 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
585 0 my ( $self ) = @_;
586 0 return _bool( _unwrap_node( $self )->hasChildNodes );
587 },
588 14 );
589  
590 $node_class->methods->{normalize} = native_function(
591 name => 'normalize',
592 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
593 0 my ( $self ) = @_;
594 0 _unwrap_node( $self )->normalize();
595 0 return $self;
596 },
597 14 );
598  
599 $node_class->methods->{appendChild} = native_function(
600 name => 'appendChild',
601 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
602 0 my ( $self, $child_obj ) = @_;
603 0 my $child = _unwrap_node( $child_obj );
604 0 my $added = _unwrap_node( $self )->appendChild( $child );
605 0 return _wrap_node( $node_classes, $added );
606 },
607 14 );
608  
609 $node_class->methods->{prependChild} = native_function(
610 name => 'prependChild',
611 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
612 0 my ( $self, $child_obj ) = @_;
613 0 my $parent = _unwrap_node( $self );
614 0 my $child = _unwrap_node( $child_obj );
615 0 my $first = $parent->firstChild;
616 0 ▶ if ( defined $first ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $first) { } 0 0 0
617 0 $parent->insertBefore( $child, $first );
618 }
619 else {
620 0 $parent->appendChild( $child );
621 }
622 0 return _wrap_node( $node_classes, $child );
623 },
624 14 );
625  
626 $node_class->methods->{insertBefore} = native_function(
627 name => 'insertBefore',
628 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
629 0 my ( $self, $new_node, $ref_node ) = @_;
630 0 my $inserted = _unwrap_node( $self )->insertBefore(
631 _unwrap_node( $new_node ),
632 _unwrap_node( $ref_node ),
633 );
634 0 return _wrap_node( $node_classes, $inserted );
635 },
636 14 );
637  
638 $node_class->methods->{replaceChild} = native_function(
639 name => 'replaceChild',
640 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
641 0 my ( $self, $new_node, $old_node ) = @_;
642 0 my $replaced = _unwrap_node( $self )->replaceChild(
643 _unwrap_node( $new_node ),
644 _unwrap_node( $old_node ),
645 );
646 0 return _wrap_node( $node_classes, $replaced );
647 },
648 14 );
649  
650 $node_class->methods->{removeChild} = native_function(
651 name => 'removeChild',
652 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
653 0 my ( $self, $child_obj ) = @_;
654 0 my $removed = _unwrap_node( $self )->removeChild(
655 _unwrap_node( $child_obj ),
656 );
657 0 return _wrap_node( $node_classes, $removed );
658 },
659 14 );
660  
661 $node_class->methods->{remove} = native_function(
662 name => 'remove',
663 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
664 0 my ( $self ) = @_;
665 0 my $node = _unwrap_node( $self );
666 0 my $parent = $node->parentNode;
667 0 ▶ if ( defined $parent ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parent) 0 0 0
668 0 $parent->removeChild( $node );
669 }
670 0 return $self;
671 },
672 14 );
673  
674 $node_class->methods->{cloneNode} = native_function(
675 name => 'cloneNode',
676 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
677 0 my ( $self, $deep ) = @_;
678 0 my $clone = _unwrap_node( $self )->cloneNode( _bool( $deep ) );
679 0 return _wrap_node( $node_classes, $clone );
680 },
681 14 );
682  
683 $node_class->methods->{isSameNode} = native_function(
684 name => 'isSameNode',
685 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
686 0 my ( $self, $other_obj ) = @_;
687 0 my $self_node = _unwrap_node( $self );
688 0 my $other_node = _unwrap_node( $other_obj );
689 0 return _bool( $self_node->isSameNode( $other_node ) );
690 },
691 14 );
692  
693 $node_class->methods->{isEqualNode} = native_function(
694 name => 'isEqualNode',
695 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
696 0 my ( $self, $other_obj ) = @_;
697 0 my $self_node = _unwrap_node( $self );
698 0 my $other_node = _unwrap_node( $other_obj );
699 0 return _bool( $self_node->isEqual( $other_node ) );
700 },
701 14 );
702  
703 $node_class->methods->{contains} = native_function(
704 name => 'contains',
705 0 ▶ native => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
706 0 my ( $self, $other_obj ) = @_;
707 0 my $self_node = _unwrap_node( $self );
708 0 my $other = _unwrap_node( $other_obj );
709 0 ▶ return 1 if $self_node->isSameNode( $other );
Branch: 1 branch
BranchTrueFalseTotal
if $self_node->isSameNode($other) 0 0 0
710 0 my $cursor = $other->parentNode;
711 0 ▶ while ( defined $cursor ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cursor) 0 0 0
712 0 ▶ return 1 if $self_node->isSameNode( $cursor );
Branch: 1 branch
BranchTrueFalseTotal
if $self_node->isSameNode($cursor) 0 0 0
713 0 $cursor = $cursor->parentNode;
714 }
715 0 return 0;
716 },
717 14 );
718  
719 14 for my $name ( qw( findnodes findvalue ) ) {
720 $node_class->methods->{$name} = native_function(
721 name => $name,
722 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
723 0 my ( $self, $xpath ) = @_;
724 0 ▶ $xpath = defined $xpath ? "$xpath" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $xpath ? : 0 0 0
725 0 ▶ if ( $name eq 'findnodes' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "findnodes") 0 0 0
726 0 my @nodes = _unwrap_node( $self )->findnodes( $xpath );
727 0 return _node_list_to_zuzu( $node_classes, @nodes );
728 }
729 0 return "" . _unwrap_node( $self )->findvalue( $xpath );
730 },
731 28 );
732 }
733  
734 14 for my $name ( qw( querySelectorAll querySelector ) ) {
735 $node_class->methods->{$name} = native_function(
736 name => $name,
737 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
738 0 my ( $self, $selector ) = @_;
739 0 my $xpath = _selector_to_xpath( $selector );
740 0 my @nodes = _unwrap_node( $self )->findnodes( $xpath );
741 0 ▶ return _node_list_to_zuzu( $node_classes, @nodes )
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "querySelectorAll" 0 0 0
742 if $name eq 'querySelectorAll';
743 0 return _wrap_node( $node_classes, $nodes[0] );
744 },
745 28 );
746 }
747  
748 $node_class->methods->{visitEach} = native_function(
749 name => 'visitEach',
750 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
751 0 my ( $self, $visitor ) = @_;
752 0 _visit_tree( $node_classes, $runtime, _unwrap_node( $self ), $visitor, 0, 1 );
753 0 return $self;
754 },
755 14 );
756  
757 $node_class->methods->{findFirst} = native_function(
758 name => 'findFirst',
759 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
760 0 my ( $self, $matcher ) = @_;
761 0 return _visit_tree( $node_classes, $runtime, _unwrap_node( $self ), $matcher, 1, 0 );
762 },
763 14 );
764  
765 $node_class->methods->{getAttribute} = native_function(
766 name => 'getAttribute',
767 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
768 0 my ( $self, $name ) = @_;
769 0 ▶ $name = defined $name ? "$name" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
770 0 my $node = _unwrap_node( $self );
771 0 ▶ return undef if not $node->can('getAttribute');
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("getAttribute") 0 0 0
772 0 my $value = $node->getAttribute( $name );
773 0 return _xml_maybe_text($value);
774 },
775 14 );
776  
777 $node_class->methods->{setAttribute} = native_function(
778 name => 'setAttribute',
779 0 ▶ native => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
780 0 my ( $self, $name, $value ) = @_;
781 0 ▶ $name = defined $name ? "$name" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
782 0 ▶ $value = defined $value ? "$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
783 0 my $node = _unwrap_node( $self );
784 0 ▶ die "setAttribute not supported by this node type"
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("setAttribute") 0 0 0
785 if not $node->can('setAttribute');
786 0 $node->setAttribute( $name, $value );
787 0 return $self;
788 },
789 14 );
790  
791 $node_class->methods->{hasAttribute} = native_function(
792 name => 'hasAttribute',
793 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
794 0 my ( $self, $name ) = @_;
795 0 ▶ $name = defined $name ? "$name" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
796 0 my $node = _unwrap_node( $self );
797 0 ▶ return 0 if not $node->can('hasAttribute');
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("hasAttribute") 0 0 0
798 0 return _bool( $node->hasAttribute( $name ) );
799 },
800 14 );
801  
802 $node_class->methods->{removeAttribute} = native_function(
803 name => 'removeAttribute',
804 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
805 0 my ( $self, $name ) = @_;
806 0 ▶ $name = defined $name ? "$name" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
807 0 my $node = _unwrap_node( $self );
808 0 ▶ die "removeAttribute not supported by this node type"
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("removeAttribute") 0 0 0
809 if not $node->can('removeAttribute');
810 0 $node->removeAttribute( $name );
811 0 return $self;
812 },
813 14 );
814  
815 $node_class->methods->{attributeNames} = native_function(
816 name => 'attributeNames',
817 0 ▶ native => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
818 0 my ( $self ) = @_;
819 0 my $node = _unwrap_node( $self );
820 0 ▶ return perl_to_zuzu( [] ) if not $node->can('attributes');
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("attributes") 0 0 0
821 0 my @names;
822 0 for my $attr ( $node->attributes ) {
823 0 push @names, $attr->nodeName;
824 }
825 0 return perl_to_zuzu( \@names );
826 },
827 14 );
828  
829 $node_class->methods->{attributes} = native_function(
830 name => 'attributes',
831 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
832 0 my ( $self ) = @_;
833 0 my $node = _unwrap_node( $self );
834 0 ▶ return perl_to_zuzu( [] ) if not $node->can('attributes');
Branch: 1 branch
BranchTrueFalseTotal
unless $node->can("attributes") 0 0 0
835 0 my @attrs = $node->attributes;
836 0 return _node_list_to_zuzu( $node_classes, @attrs );
837 },
838 14 );
839  
840 $node_class->methods->{toXML} = native_function(
841 name => 'toXML',
842 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
843 0 my ( $self, $pretty ) = @_;
844 0 return _xml_text( _unwrap_node( $self )->toString( _bool( $pretty ) ) );
845 },
846 14 );
847  
848 $node_class->methods->{to_String} = native_function(
849 name => 'to_String',
850 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
851 0 my ( $self ) = @_;
852 0 return _xml_text( _unwrap_node( $self )->toString(0) );
853 },
854 14 );
855  
856 $dom_element_class->methods->{tagName} = native_function(
857 name => 'tagName',
858 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
859 0 my ( $self ) = @_;
860 0 return "" . _unwrap_node( $self )->nodeName;
861 },
862 14 );
863  
864 $dom_element_class->methods->{id} = native_function(
865 name => 'id',
866 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
867 0 my ( $self ) = @_;
868 0 my $value = _unwrap_node( $self )->getAttribute('id');
869 0 return _xml_maybe_text($value);
870 },
871 14 );
872  
873 $dom_element_class->methods->{setId} = native_function(
874 name => 'setId',
875 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
876 0 my ( $self, $id ) = @_;
877 0 ▶ $id = defined $id ? "$id" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $id ? : 0 0 0
878 0 _unwrap_node( $self )->setAttribute( 'id', $id );
879 0 return $self;
880 },
881 14 );
882  
883 $dom_element_class->methods->{getElementsByTagName} = native_function(
884 name => 'getElementsByTagName',
885 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
886 0 my ( $self, $name ) = @_;
887 0 ▶ $name = defined $name ? "$name" : '*';
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 0 0
888 0 my @nodes = _unwrap_node( $self )->getElementsByTagName( $name );
889 0 return _node_list_to_zuzu( $node_classes, @nodes );
890 },
891 14 );
892  
893 14 for my $class ( $dom_text_class, $dom_comment_class ) {
894 $class->methods->{data} = native_function(
895 name => 'data',
896 0 ▶ native => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
897 0 my ( $self ) = @_;
898 0 return "" . _unwrap_node( $self )->data;
899 },
900 28 );
901  
902 $class->methods->{setData} = native_function(
903 name => 'setData',
904 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
905 0 my ( $self, $value ) = @_;
906 0 ▶ $value = defined $value ? "$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 0 0 0
907 0 _unwrap_node( $self )->setData( $value );
908 0 return $self;
909 },
910 28 );
911 }
912  
913 return {
914 14 XML => $xml_class,
915 XMLDocument => $doc_class,
916 XMLNode => $node_class,
917 DOMNode => $dom_node_class,
918 DOMDocument => $dom_doc_class,
919 DOMElement => $dom_element_class,
920 DOMComment => $dom_comment_class,
921 DOMText => $dom_text_class,
922 };
923 }
924  
925 4 1;
926  
927 =pod
928  
929 =head1 NAME
930  
931 Zuzu::Module::XML - C<std/data/xml> bindings for ZuzuScript.
932  
933 =head1 DESCRIPTION
934  
935 Implements XML DOM parsing and manipulation for C<std/data/xml>, backed by
936 C<XML::LibXML>.
937  
938 Exports classes C<XML>, C<XMLDocument>, and C<XMLNode>.
939  
940 =head1 COPYRIGHT AND LICENCE
941  
942 B<< Zuzu::Module::XML >> is copyright Toby Inkster.
943  
944 It is free software; you may redistribute it and/or modify it under
945 the terms of either the Artistic License 1.0 or the GNU General Public
946 License version 2.
947  
948 =cut
« blib/lib/Zuzu/Module/JSON.pm ↑ Summary blib/lib/Zuzu/Value/PairList.pm »