blib/lib/Data/Dump/XML.pm

filter: Statementstmt 72.4% 113 / 156 Branchbran 63.5% 47 / 74 Conditioncond 54.1% 39 / 72 MC/DCmcdc 29.7% 11 / 37 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 5 totaltotal 61.5% 216 / 351 CC 67 SCAR 40.3
CC
67
Cov
66%
simple_dump
100.3
dump_hashref_pp
24.5
key_info_pp
20.0
CRAP 56.0
↑ Summary blib/lib/Data/Dump/XML/Parser.pm »
1 package Data::Dump::XML;
2  
3 5 ▶use Class::Easy;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use XML::LibXML ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 our $VERSION = '1.19'; # avoid locale issues by stringified version
8  
9 5 require XSLoader;
10 5 XSLoader::load ('Data::Dump::XML', $VERSION);
11  
12 5 our $defaults = {
13 # xml configuration
14 encoding => 'utf-8',
15 dtd_location => '',
16 namespace => {},
17
18 # xml tree namespace
19 dump_config => 1,
20 root_name => 'data',
21 hash_element => 'key',
22 array_element => 'item',
23 ref_element => 'ref',
24 empty_array => 'empty-array',
25 empty_hash => 'empty-hash',
26 undef => 'undef',
27 key_as_hash_element => 1,
28 hash_element_attribute_name => '_name',
29 at_key_as_attribute => 1,
30
31 # options
32 sort_keys => 0,
33 granted_restore => 1,
34 ignore_bless => 0,
35
36 # internal structure
37 doc_object => undef,
38 references => {},
39 ref_count => 0,
40 used => {},
41 };
42  
43 5 1;
44 ############################################################
45 9 ▶sub new {
Subroutine new: called CC=4 SCAR=14.2
Pod undocumented
46 9 my $class = shift;
47 9 my $params = {@_};
48
49 9 my $config = {%$defaults};
50
51 9 foreach my $key (keys %$params) {
52 1 ▶ if (exists $config->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config->{$key}) 1 0 1
53 1 $config->{$key} = $params->{$key};
54 }
55 }
56  
57 9 ▶ if (exists $config->{'@key_as_attribute'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $config->{"\@key_as_attribute"}) 0 9 9
58 0 $config->{at_key_as_attribute} = delete $config->{'@key_as_attribute'};
59 }
60
61 9 bless $config, $class;
62
63 9 return $config;
64 }
65 ############################################################
66 17 ▶sub dump_xml {
Subroutine dump_xml: called CC=9 SCAR=22.9
Pod undocumented
67 17 my $self = shift;
68  
69 17 my $structure;
70 my $root;
71  
72 17 my $dom = XML::LibXML->createDocument ('1.0', $self->{encoding});
73 17 $self->{doc_object} = $dom;
74
75
76 17 ▶ if ($self->{dtd_location} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"dtd_location"} ne "") 0 17 17
77 0 $dom->createInternalSubset ('data', undef, $self->{dtd_location});
78 }
79
80 17 $root = $dom->createElement ($self->{root_name});
81 17 $dom->setDocumentElement ($root);
82  
83  
84 17 ▶ if ((scalar @_) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ == 1) { } 17 0 17
85 17 $structure = shift;
86  
87 17 ▶ if (blessed ($structure) and $structure->can ('TO_XML')) {
Branch: 1 branch
BranchTrueFalseTotal
if (&blessed($structure) and $structure->can("TO_XML")) 1 16 17
Condition100%3/3
&blessed($structure) and $structure->can("TO_XML")
!ll&&!rl&&r
1511
MC/DC100%2/2
&blessed($structure) and $structure->can("TO_XML")
&blessed($structure) $structure->can("TO_XML")
Truth table100%3/3
A and B
A= &blessed($structure)B= $structure->can("TO_XML")
ABresult
0X0
100
111
88 1 $root->setAttribute (_class => blessed ($structure));
89 1 $structure = $structure->TO_XML;
90 1 $root->setAttribute (_to_xml => 1);
91 }
92  
93 } else {
94 0 $structure = \@_;
95 }
96
97
98 # dump config options if any
99 17 foreach (qw(ref_element hash_element array_element empty_array empty_hash undef key_as_hash_element at_key_as_attribute)) {
100 $root->setAttribute ("_$_", $self->{$_})
101 136 ▶ if $self->{$_} ne $defaults->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$_} ne $Data::Dump::XML::defaults->{$_} 0 136 136
102 }
103
104 17 ▶ if (scalar keys %{$self->{namespace}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %{$$self{"namespace"};}) 0 17 17
105 0 foreach my $key (keys %{$self->{namespace}}) {
106 0 $root->setAttribute ($key, $self->{namespace}->{$key});
107 #debug "add '$key' namespace";
108 }
109 }
110
111 17 $self->{references} = {};
112 17 $self->{ref_count} = 0;
113 17 $self->{used} = {};
114
115 # $self->analyze ($structure);
116
117 #my $refs = $self->{'references'};
118 #
119 #foreach (keys %$refs)
120 #{
121 # delete $refs->{$_} unless ($refs->{$_});
122 #}
123
124 17 $self->simple_dump ($structure);
125
126 17 return $self->{doc_object};
127
128 }
129 ############################################################
130 4602 ▶sub simple_dump {
Subroutine simple_dump: called CC=34 SCAR=46.1
Pod undocumented
131 4602 my $self = shift;
132 4602 my $rval = \$_[0]; shift;
133
134 4602 my $dom = $self->{doc_object};
135  
136 4602 ▶ my $tag = shift || $dom->documentElement;
Condition66%2/3
shift() || $dom->documentElement
l!l&&r!l&&!r
4573290
MC/DC0%0/2
shift() || $dom->documentElement
shift() $dom->documentElement
Truth table66%2/3
A || B
A= shift()B= $dom->documentElement
ABresult
1X1
011
000
137 4602 my $deref = shift;
138  
139 4602 ▶ $rval = $$rval if $deref;
Branch: 1 branch
BranchTrueFalseTotal
if $deref 799 3803 4602
140
141 4602 my $ref_element = $self->{ref_element};
142 4602 my $array_element = $self->{array_element};
143 4602 my $hash_element = $self->{hash_element};
144 4602 my $empty_array = $self->{empty_array};
145 4602 my $undef = $self->{undef};
146 4602 my $empty_hash = $self->{empty_hash};
147
148 4602 my ($class, $type, $id) = (
149 blessed ($rval),
150 reftype ($rval),
151 refaddr ($rval)
152 );
153
154 4602 ▶ if (defined $class) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $class) 2 4600 4602
155 2 ▶ if ($class eq 'XML::LibXML::Element') {
Branch: 2 branches
BranchTrueFalseTotal
if ($class eq 'XML::LibXML::Element') { } 0 2 2
elsif ($class ne '') { } 2 0 2
156
157 0 ▶ if ($rval->localname eq 'include' and (
Branch: 1 branch
BranchTrueFalseTotal
if ($rval->localname eq 'include' and $rval->lookupNamespacePrefix('http://www.w3.org/2003/XInclude') || $rval->lookupNamespacePrefix('http://www.w3.org/2001/XInclude')) { } 0 0 0
Condition0%0/6
$rval->localname eq "include" and $rval->lookupNamespacePrefix("http://www.w3.org/2003/XInclude") || $rval->lookupNamespacePrefix("http://www.w3.org/2001/XInclude")
!ll&&!rl&&r
000
$rval->lookupNamespacePrefix("http://www.w3.org/2003/XInclude") or $rval->lookupNamespacePrefix("http://www.w3.org/2001/XInclude")
l!l&&r!l&&!r
000
MC/DC0%0/3
$rval->localname eq "include" and $rval->lookupNamespacePrefix("http://www.w3.org/2003/XInclude") || $rval->lookupNamespacePrefix("http://www.w3.org/2001/XInclude")
$rval->localname eq "include" $rval->lookupNamespacePrefix("http://www.w3.org/2003/XInclude") $rval->lookupNamespacePrefix("http://www.w3.org/2001/XInclude")
Truth table0%0/4
A and B or C
A= $rval->localname eq "include"B= $rval->lookupNamespacePrefix("http://www.w3.org/2003/XInclude")C= $rval->lookupNamespacePrefix("http://www.w3.org/2001/XInclude")
ABCresult
0XX0
1000
11X1
1011
158 $rval->lookupNamespacePrefix ('http://www.w3.org/2003/XInclude')
159 or $rval->lookupNamespacePrefix ('http://www.w3.org/2001/XInclude')
160 )) {
161 #my $node = $tag->addNewChild ('', 'include');
162 #$node->setNamespace ('http://www.w3.org/2003/XInclude', 'xi');
163 #$node->setAttribute ('href', $rval->getAttribute ('href'));
164
165 0 my $parser = XML::LibXML->new;
166 0 $parser->expand_xinclude(0); # we try this later
167 0 $parser->load_ext_dtd(0);
168 0 $parser->expand_entities(0);
169
170 0 my $include;
171 0 eval {
172 0 $include = $parser->parse_file ($rval->getAttribute ('href'));
173 };
174 #my $xinclude_result;
175 #eval {$xinclude_result = $parser->process_xincludes ($include);};
176  
177 #debug "XInclude processing result is: $xinclude_result, error is: $@";
178
179 0 ▶ $tag->addChild ($include->documentElement)
Branch: 1 branch
BranchTrueFalseTotal
if not $@ and defined $include 0 0 0
Condition0%0/3
not $@ and defined $include
!ll&&!rl&&r
000
MC/DC0%0/2
not $@ and defined $include
not $@ defined $include
Truth table0%0/3
not(A) and B
A= not $@B= defined $include
ABresult
0X0
100
111
180 if not $@ and defined $include;
181
182 } else {
183 0 $tag->addChild ($rval);
184 }
185
186 0 return;
187 } elsif ($class ne '') {
188
189 2 $tag->setAttribute (_class => $class);
190
191 2 ▶ if ($rval->can ('TO_XML')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rval->can("TO_XML")) 0 2 2
192 0 $rval = $rval->TO_XML;
193 0 $tag->setAttribute (_to_xml => 1);
194 0 ($class, $type, $id) = (
195 blessed ($rval),
196 reftype ($rval),
197 refaddr ($rval)
198 );
199 }
200
201  
202 }
203 }
204
205 #if (my $ref_no = $self->refs ($id)) {
206 # if (defined $self->{'used'}->{$id}
207 # and $self->{'used'}->{$id} eq 'yea'
208 # ) {
209 #
210 # my $node = $tag->addNewChild ('', $ref_element);
211 # $node->setAttribute ('to', $ref_no);
212 # return;
213 #
214 # } else {
215 #
216 # $tag->setAttribute ('id', $ref_no);
217 # $self->{'used'}->{$id} = 'yea';
218 #
219 # }
220 #}
221
222 4602 ▶ if ($type eq "SCALAR" || $type eq "REF"){
Branch: 5 branches
BranchTrueFalseTotal
if ($type eq 'SCALAR' or $type eq 'REF') { } 3803 799 4602
elsif ($type eq 'ARRAY') { } 125 674 799
elsif ($type eq 'HASH') { } 674 0 674
elsif ($type eq 'GLOB') { } 0 0 0
elsif ($type eq 'CODE') { } 0 0 0
Condition100%3/3
$type eq "SCALAR" or $type eq "REF"
l!l&&r!l&&!r
3004799799
MC/DC100%2/2
$type eq "SCALAR" or $type eq "REF"
$type eq "SCALAR" $type eq "REF"
Truth table100%3/3
A or B
A= $type eq "SCALAR"B= $type eq "REF"
ABresult
1X1
011
000
223
224 3803 my $rval_ref = ref $$rval;
225
226 3803 ▶ if ($rval_ref) {
Branch: 3 branches
BranchTrueFalseTotal
if ($rval_ref) { } 799 3004 3803
elsif (not defined $$rval and defined $rval and defined $class and $class ne '') { } 0 3004 3004
elsif (not defined $$rval) { } 48 2956 3004
227
228 799 ▶ if (($rval_ref eq 'SCALAR') or ($rval_ref eq 'REF')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rval_ref eq "SCALAR" or $rval_ref eq "REF") 0 799 799
Condition33%1/3
$rval_ref eq "SCALAR" or $rval_ref eq "REF"
l!l&&r!l&&!r
00799
MC/DC0%0/2
$rval_ref eq "SCALAR" or $rval_ref eq "REF"
$rval_ref eq "SCALAR" $rval_ref eq "REF"
Truth table33%1/3
A or B
A= $rval_ref eq "SCALAR"B= $rval_ref eq "REF"
ABresult
1X1
011
000
229
230 0 my $node = $tag->addNewChild ('', $ref_element);
231 0 return $self->simple_dump ($$rval, $node, 1);
232 }
233
234 799 return $self->simple_dump ($$rval, $tag, 1);
235
236 ▶ } elsif (
Condition55%5/9
not defined $$rval and defined $rval and defined $class and $class ne ""
!ll&&!rl&&r
300400
not defined $$rval and defined $rval and defined $class
!ll&&!rl&&r
2956480
not defined $$rval and defined $rval
!ll&&!rl&&r
2956048
MC/DC0%0/4
not defined $$rval and defined $rval and defined $class and $class ne ""
not defined $$rval defined $rval defined $class $class ne ""
Truth table40%2/5
not(A) and B and C and D
A= not defined $$rvalB= defined $rvalC= defined $classD= $class ne ""
ABCDresult
0XXX0
10XX0
110X0
11100
11111
237 not defined $$rval and defined $rval
238 and defined $class and $class ne ''
239 ) {
240 # regexp. 100% ?
241 # debug "has undefined deref '$$rval' and defined '$rval'";
242 0 $tag->addNewChild ('', $rval);
243
244 } elsif (not defined $$rval) {
245
246 48 $tag->addNewChild ('', $self->{undef});
247
248 } else {
249
250 2956 $tag->appendText ($$rval);
251
252 }
253
254 #debug $rval, $$rval, ref $rval, ref $$rval;
255
256 3004 return;
257 } elsif ($type eq "ARRAY") {
258 125 my @array;
259
260 125 ▶ unless (scalar @$rval){
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @$rval) 60 65 125
261 60 $tag->addNewChild ('', $self->{empty_array});
262 60 return;
263 }
264
265 65 my $level_up = 0;
266 65 my $option_attr = $tag->getAttribute ('_opt');
267 65 ▶ if (defined $option_attr and $option_attr eq 'up') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $option_attr and $option_attr eq "up") 1 64 65
Condition66%2/3
defined $option_attr and $option_attr eq "up"
!ll&&!rl&&r
6401
MC/DC50%1/2
defined $option_attr and $option_attr eq "up"
defined $option_attr $option_attr eq "up"
Truth table66%2/3
A and B
A= defined $option_attrB= $option_attr eq "up"
ABresult
0X0
100
111
268 1 $level_up = 1;
269 }
270
271 65 my $idx = 0;
272 65 my $tag_name = $tag->nodeName;
273 # debug "tag mane is : $tag_name, level up is : $level_up";
274
275 65 foreach (@$rval) {
276 459 my $node;
277 459 ▶ if ($level_up) {
Branch: 1 branch
BranchTrueFalseTotal
if ($level_up) { } 1 458 459
278 1 ▶ if ($idx) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idx) { } 0 1 1
279 0 $node = $tag->parentNode->addNewChild ('', $tag_name);
280 } else {
281 1 $node = $tag;
282 1 $tag->removeAttribute ('_opt');
283 }
284 # $tag->setAttribute ('idx', $idx);
285 } else {
286 458 $node = $tag->addNewChild ('', $array_element);
287 }
288
289 459 $idx++;
290 459 $self->simple_dump ($_, $node);
291 }
292
293 65 return;
294 } elsif ($type eq "HASH") {
295
296 674 my @keys = keys %$rval;
297
298 674 ▶ unless (scalar @keys) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @keys) 48 626 674
299 48 $tag->addNewChild ('', $self->{empty_hash});
300 48 return;
301 }
302
303 @keys = sort @keys
304 626 ▶ if $self->{sort_keys};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sort_keys"} 0 626 626
305
306 #$self->dump_hashref ($rval, \@keys, $tag);
307 626 $self->dump_hashref_pp ($rval, \@keys, $tag);
308
309 626 return;
310
311 } elsif ($type eq "GLOB") {
312  
313 0 $tag->addNewChild ('', 'glob');
314 0 return;
315  
316 } elsif ($type eq "CODE") {
317  
318 0 $tag->addNewChild ('', 'code');
319 0 return;
320  
321 } else {
322 0 my $comment = $dom->createComment ("unknown type: '$type'");
323 0 $tag->addChild ($comment);
324 0 return;
325 }
326
327 0 die "Assert";
328 }
329 ############################################################
330 0 ▶sub key_info_pp {
Subroutine key_info_pp: not called CC=4 SCAR=30.0
Pod undocumented
331 0 my $self = shift;
332 0 my ($rval, $key, $val_ref) = @_;
333
334 0 my $key_prefix = substr $key, 0, 1;
335 0 my $key_name = substr $key, 1;
336
337 0 ▶ if ($key_prefix ne '@' and $key_prefix ne '#' and $key_prefix ne '<') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key_prefix ne "\@" and $key_prefix ne "#" and $key_prefix ne "<") 0 0 0
Condition0%0/6
$key_prefix ne "\@" and $key_prefix ne "#" and $key_prefix ne "<"
!ll&&!rl&&r
000
$key_prefix ne "\@" and $key_prefix ne "#"
!ll&&!rl&&r
000
MC/DC0%0/3
$key_prefix ne "\@" and $key_prefix ne "#" and $key_prefix ne "<"
$key_prefix ne "\@" $key_prefix ne "#" $key_prefix ne "<"
Truth table0%0/4
A and B and C
A= $key_prefix ne "\@"B= $key_prefix ne "#"C= $key_prefix ne "<"
ABCresult
0XX0
10X0
1100
1111
338 0 $key_name = $key;
339 }
340
341 0 my $val_type = reftype ($val_ref);
342
343 # [4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
344 # [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
345 0 my $key_can_be_tag = $key_name =~ /^[a-zA-Z\:\_][\w\d\_\-\:\.]$/;
346
347 0 return ($key_prefix, $key_name, $val_type, $key_can_be_tag);
348
349 }
350 ############################################################
351 626 ▶sub dump_hashref_pp {
Subroutine dump_hashref_pp: called CC=20 SCAR=32.0
Pod undocumented
352 626 my $self = shift;
353 626 my ($rval, $keys, $tag) = @_;
354
355 626 foreach my $key (@$keys) {
356
357 3827 my $val = \$rval->{$key};
358 3827 my $node;
359  
360 3827 my ($key_prefix, $key_name, $val_type, $key_can_be_tag) =
361 $self->key_info ($rval, $key, $$val);
362
363 3827 ▶ if ($key_can_be_tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key_can_be_tag) { } 3827 0 3827
364 3827 ▶ if (defined $key_prefix and $key_prefix eq '@' and $self->{at_key_as_attribute}) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $key_prefix and $key_prefix eq '@' and $self->{'at_key_as_attribute'}) { } 485 3342 3827
elsif (defined $key_prefix and $key_prefix eq '#' and $key_name eq 'text') { } 15 3327 3342
elsif ($self->{'key_as_hash_element'} and $key ne $self->{'array_element'} and $key ne $self->{'hash_element'} and $key ne $self->{'ref_element'} and $key ne $self->{'empty_array'} and $key ne $self->{'empty_hash'} and $key ne $self->{'undef'}) { } 3315 24 3339
Condition83%5/6
defined $key_prefix and $key_prefix eq "\@" and $self->{"at_key_as_attribute"}
!ll&&!rl&&r
33420485
defined $key_prefix and $key_prefix eq "\@"
!ll&&!rl&&r
332616485
MC/DC66%2/3
defined $key_prefix and $key_prefix eq "\@" and $self->{"at_key_as_attribute"}
defined $key_prefix $key_prefix eq "\@" $self->{"at_key_as_attribute"}
Truth table75%3/4
A and B and C
A= defined $key_prefixB= $key_prefix eq "\@"C= $self->{"at_key_as_attribute"}
ABCresult
0XX0
10X0
1100
1111
365 # TODO: make something with values other than scalar ref
366
367 485 ▶ unless (defined $val_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val_type) 485 0 485
368 485 $tag->setAttribute ($key_name, $$val);
369 485 next;
370 }
371
372 ▶ } elsif (defined $key_prefix and $key_prefix eq '#' and $key_name eq 'text') {
Condition83%5/6
defined $key_prefix and $key_prefix eq "#" and $key_name eq "text"
!ll&&!rl&&r
3327015
defined $key_prefix and $key_prefix eq "#"
!ll&&!rl&&r
3326115
MC/DC66%2/3
defined $key_prefix and $key_prefix eq "#" and $key_name eq "text"
defined $key_prefix $key_prefix eq "#" $key_name eq "text"
Truth table75%3/4
A and B and C
A= defined $key_prefixB= $key_prefix eq "#"C= $key_name eq "text"
ABCresult
0XX0
10X0
1100
1111
373 15 ▶ unless (defined $val_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $val_type) 15 0 15
374 15 $tag->appendText ($$val);
375 15 next;
376 }
377 ▶ } elsif (
Condition61%11/18
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"} and $key ne $self->{"hash_element"} and $key ne $self->{"ref_element"} and $key ne $self->{"empty_array"} and $key ne $self->{"empty_hash"} and $key ne $self->{"undef"}
!ll&&!rl&&r
1203315
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"} and $key ne $self->{"hash_element"} and $key ne $self->{"ref_element"} and $key ne $self->{"empty_array"} and $key ne $self->{"empty_hash"}
!ll&&!rl&&r
1203315
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"} and $key ne $self->{"hash_element"} and $key ne $self->{"ref_element"} and $key ne $self->{"empty_array"}
!ll&&!rl&&r
1203315
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"} and $key ne $self->{"hash_element"} and $key ne $self->{"ref_element"}
!ll&&!rl&&r
1203315
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"} and $key ne $self->{"hash_element"}
!ll&&!rl&&r
0123315
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"}
!ll&&!rl&&r
003327
MC/DC14%1/7
$self->{"key_as_hash_element"} and $key ne $self->{"array_element"} and $key ne $self->{"hash_element"} and $key ne $self->{"ref_element"} and $key ne $self->{"empty_array"} and $key ne $self->{"empty_hash"} and $key ne $self->{"undef"}
$self->{"key_as_hash_element"} $key ne $self->{"array_element"} $key ne $self->{"hash_element"} $key ne $self->{"ref_element"} $key ne $self->{"empty_array"} $key ne $self->{"empty_hash"} $key ne $self->{"undef"}
Truth table25%2/8
A and B and C and D and E and F and G
A= $self->{"key_as_hash_element"}B= $key ne $self->{"array_element"}C= $key ne $self->{"hash_element"}D= $key ne $self->{"ref_element"}E= $key ne $self->{"empty_array"}F= $key ne $self->{"empty_hash"}G= $key ne $self->{"undef"}
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11110XX0
111110X0
11111100
11111111
378 $self->{key_as_hash_element}
379 and $key ne $self->{array_element} # for RSS
380 and $key ne $self->{hash_element}
381 and $key ne $self->{ref_element}
382 and $key ne $self->{empty_array}
383 and $key ne $self->{empty_hash}
384 and $key ne $self->{undef}
385 ) {
386 3315 $node = $tag->addNewChild ('', $key_name);
387 3315 ▶ if (defined $key_prefix and $key_prefix eq '<') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key_prefix and $key_prefix eq "<") 1 3314 3315
Condition66%2/3
defined $key_prefix and $key_prefix eq "<"
!ll&&!rl&&r
331401
MC/DC50%1/2
defined $key_prefix and $key_prefix eq "<"
defined $key_prefix $key_prefix eq "<"
Truth table66%2/3
A and B
A= defined $key_prefixB= $key_prefix eq "<"
ABresult
0X0
100
111
388 1 $node->setAttribute (_opt => 'up');
389 }
390 }
391 } else {
392 0 $node = $tag->addNewChild ('', $self->{hash_element});
393 0 $node->setAttribute ($self->{hash_element_attribute_name}, $key);
394 }
395
396 3327 $self->simple_dump ($$val, $node);
397 }
398
399 }
400  
401 ############################################################
402 __END__
↑ Summary blib/lib/Data/Dump/XML/Parser.pm »