Generator/Common.pm

filter: Statementstmt 82.6% 81 / 98 Branchbran 44.1% 15 / 34 Conditioncond 33.3% 13 / 39 MC/DCmcdc 17.3% 4 / 23 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 59.9% 121 / 202 CC 38 SCAR 43.3
CC
38
Cov
64%
__xforms_children
106.0
__xforms_attribute
16.0
BEGIN
1.0
CRAP 76.0
« Generator/Model.pm ↑ Summary Generator/UserInterface.pm »
1 package XML::XForms::Generator::Common;
2 ######################################################################
3 ## ##
4 ## Package: Common.pm ##
5 ## Author: D. Hageman <dhageman@dracken.com> ##
6 ## ##
7 ## Description: ##
8 ## ##
9 ## Perl object to assist in the generation of XML compliant with ##
10 ## the W3's XForms specification. ##
11 ## ##
12 ######################################################################
13  
14 ##==================================================================##
15 ## Libraries and Variables ##
16 ##==================================================================##
17  
18 5 require 5.006;
19 5 require Exporter;
20  
21 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 5 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 5 our @ISA = qw( Exporter XML::LibXML::Element );
28  
29 5 our $VERSION = "0.70";
30  
31 5 our @EXPORT = qw( __xforms_attribute
32 __xforms_children
33 @XFORMS_ACTION
34 @XFORMS_ATTRIBUTE_UICOMMON
35 @XFORMS_ATTRIBUTE_LINKING
36 @XFORMS_ATTRIBUTE_NODESET
37 @XFORMS_ATTRIBUTE_SINGLENODE
38 @XFORMS_CONTROL
39 @XFORMS_CONTROL_ELEMENT
40 @XFORMS_MODEL_ELEMENT
41 @XFORMS_USERINTERFACE
42 @XFORMS_USERINTERFACE_ELEMENT
43 %XFORMS_SCHEMA
44 %XFORMS_NAMESPACE );
45  
46 ## Potential namespaces used exclusively by the XForms generator.
47 5 our %XFORMS_NAMESPACE = (
48 "xforms" => "http://www.w3.org/2002/xforms/cr",
49 "xlink" => "http://www.w3.org/1999/xlink",
50 "xsd" => "http://www.w3.org/2001/XMLSchema",
51 "xsi" => "http://www.w3.org/2000/10/XMLSchema-instance",
52 "ev" => "http://www.w3.org/2001/xml-events" );
53  
54 5 our @XFORMS_ATTRIBUTE_EVENT = qw( ev:event ev:observer ev:target ev:handler
55 ev:phase ev:propagate ev:defaultAction );
56  
57 ## XForms Common Attributes
58 5 our @XFORMS_ATTRIBUTE_UICOMMON = qw( accesskey navindex appearance );
59  
60 ## XForms Linking Attributes
61 5 our @XFORMS_ATTRIBUTE_LINKING = qw( src );
62  
63 ### XForms Nodeset Binding Attributes
64 5 our @XFORMS_ATTRIBUTE_NODESET = qw( nodeset model bind );
65  
66 ### XForms Single Node Binding Attributes
67 5 our @XFORMS_ATTRIBUTE_SINGLENODE = qw( ref model bind );
68  
69 5 our @XFORMS_MODEL_ELEMENT = qw( xforms:bind xforms:extension
70 xforms:instance xforms:submission );
71  
72 ## XForms Control Elements
73 5 our @XFORMS_CONTROL = qw( xforms:input xforms:secret xforms:textarea
74 xforms:output xforms:upload xforms:range
75 xforms:trigger xforms:submit xforms:select
76 xforms:select1 xforms:item );
77  
78 ## XForms Control Child Elements
79 5 our @XFORMS_CONTROL_ELEMENT = qw( xforms:alert xforms:choices xforms:filename
80 xforms:help xforms:hint xforms:item
81 xforms:itemset xforms:label xforms:mediatype
82 xforms:extension xforms:value);
83  
84 ## XForms User Interface Elements
85 5 our @XFORMS_USERINTERFACE = qw( xforms:group xforms:switch xforms:repeat );
86  
87 ## XForms User Interface Child Elements
88 5 our @XFORMS_USERINTERFACE_ELEMENT = qw( xforms:label xforms:case xforms:toggle );
89  
90 5 our @XFORMS_ACTION = qw( xforms:action xforms:dispatch xforms:rebuild
91 xforms:recalculate xforms:revalidate xforms:refresh
92 xforms:setfocus xforms:load xforms:setvalue
93 xforms:send xforms:reset xforms:message );
94  
95 ## XForms Model Element
96 5 our %XFORMS_SCHEMA = (
97 "xforms:alert" => [ [],
98 [ @XFORMS_ATTRIBUTE_SINGLENODE,
99 @XFORMS_ATTRIBUTE_LINKING ],
100 1,
101 [],
102 [ "xforms:output", "##OTHER##"] ],
103 "xforms:bind" => [ [ "id" ],
104 [ @XFORMS_ATTRIBUTE_NODESET,
105 "calculate", "constraint", "maxOccurs",
106 "minOccurs", "p3ptype", "relevant",
107 "required", "type", ],
108 1,
109 [],
110 [ "xforms:bind" ], ],
111 "xforms:choices" => [ [],
112 [],
113 0,
114 [],
115 [ "xforms:label", "xforms:choices",
116 "xforms:item", "xforms:itemset"] ],
117 "xforms:filename" => [ [],
118 [ @XFORMS_ATTRIBUTE_SINGLENODE ],
119 0,
120 [],
121 [] ],
122 "xforms:extension" => [ [],
123 [],
124 1,
125 [],
126 [ "##OTHER##" ] ],
127 "xforms:model" => [ [ "id" ],
128 [ "functions", "schema" ],
129 0,
130 [],
131 [ "xforms:bind", "xforms:extension",
132 "xforms:instance", "xforms:submission",
133 @XFORMS_ACTION ] ],
134 "xforms:instance" => [ [],
135 [ @XFORMS_ATTRIBUTE_LINKING ],
136 0,
137 [ "##ANYDOM##" ],
138 [], ],
139 "xforms:submission" => [ [ "action", "method", "id" ],
140 [ "cdata-section-elements", "encoding",
141 "indent", "omit-xml-declaration",
142 "ref", "replace", "seperator",
143 "standalone", "version" ],
144 1,
145 [],
146 [ @XFORMS_ACTION ], ],
147 "xforms:input" => [ [],
148 [ @XFORMS_ATTRIBUTE_UICOMMON,
149 @XFORMS_ATTRIBUTE_SINGLENODE,
150 "inputmode", "incremental" ],
151 0,
152 [ "xforms:label" ],
153 [ "help", "hint", "alert",
154 @XFORMS_ACTION, "extension" ], ],
155 "xforms:secret" => [ [],
156 [ @XFORMS_ATTRIBUTE_UICOMMON,
157 @XFORMS_ATTRIBUTE_SINGLENODE,
158 "inputmode", "incremental" ],
159 0,
160 [ "xforms:label" ],
161 [ "help", "hint", "alert",
162 @XFORMS_ACTION, "extension" ], ],
163 "xforms:textarea" => [ [],
164 [ @XFORMS_ATTRIBUTE_UICOMMON,
165 @XFORMS_ATTRIBUTE_SINGLENODE,
166 "inputmode", "incremental" ],
167 0,
168 [ "xforms:label" ],
169 [ "help", "hint", "alert",
170 @XFORMS_ACTION, "extension" ], ],
171 "xforms:output" => [ [],
172 [ @XFORMS_ATTRIBUTE_SINGLENODE,
173 "appearance",
174 "value" ],
175 0,
176 [],
177 [ "xforms:label" ] ],
178 "xforms:upload" => [ [],
179 [ @XFORMS_ATTRIBUTE_UICOMMON,
180 @XFORMS_ATTRIBUTE_SINGLENODE,
181 "incremental", "mediatype" ],
182 0,
183 [ "xforms:label" ],
184 [ "filename", "mediatype", "help", "hint",
185 "alert", @XFORMS_ACTION, "extension" ], ],
186 "xforms:range" => [ [],
187 [ @XFORMS_ATTRIBUTE_UICOMMON,
188 @XFORMS_ATTRIBUTE_SINGLENODE,
189 "end", "incremental", "start", "step" ],
190 0,
191 [ "xforms:label" ],
192 [ "help", "hint", "alert",
193 @XFORMS_ACTION, "extension" ], ],
194 "xforms:trigger" => [ [],
195 [ @XFORMS_ATTRIBUTE_UICOMMON,
196 @XFORMS_ATTRIBUTE_SINGLENODE ],
197 0,
198 [ "xforms:label" ],
199 [ "help", "hint", "alert",
200 @XFORMS_ACTION, "extension" ], ],
201 "xforms:submit" => [ [ "submission" ],
202 [ @XFORMS_ATTRIBUTE_UICOMMON,
203 @XFORMS_ATTRIBUTE_SINGLENODE ],
204 0,
205 [ "xforms:label" ],
206 [ "help", "hint", "alert",
207 @XFORMS_ACTION, "extension" ], ],
208 "xforms:select" => [ [],
209 [ @XFORMS_ATTRIBUTE_UICOMMON,
210 @XFORMS_ATTRIBUTE_SINGLENODE,
211 "incremental" ],
212 0,
213 [ "xforms:label" ],
214 [ "choices", "item", "itemset",
215 "help", "hint", "alert",
216 @XFORMS_ACTION, "extension" ], ],
217 "xforms:select1" => [ [],
218 [ @XFORMS_ATTRIBUTE_UICOMMON,
219 @XFORMS_ATTRIBUTE_SINGLENODE,
220 "incremental", "selection" ],
221 0,
222 [ "xforms:label" ],
223 [ "choices", "item", "itemset",
224 "help", "hint", "alert",
225 @XFORMS_ACTION, "extension" ], ],
226 "xforms:help" => [ [],
227 [ @XFORMS_ATTRIBUTE_SINGLENODE,
228 @XFORMS_ATTRIBUTE_LINKING ],
229 1,
230 [],
231 [ "xforms:output", "##OTHER##" ] ],
232 "xforms:hint" => [ [],
233 [ @XFORMS_ATTRIBUTE_SINGLENODE,
234 @XFORMS_ATTRIBUTE_LINKING ],
235 1,
236 [],
237 [ "xforms:output", "##OTHER##" ] ],
238 "xforms:item" => [ [],
239 [],
240 0,
241 [ "xforms:label", "xforms:value" ],
242 [ "help", "hint", "alert",
243 @XFORMS_ACTION, "extension" ], ],
244 "xforms:itemset" => [ [],
245 [ @XFORMS_ATTRIBUTE_NODESET],
246 0,
247 [ "xforms:label" ],
248 [ "xforms:item", "xforms:copy",
249 "help", "hint", "alert",
250 @XFORMS_ACTION, "extension" ], ],
251 "xforms:label" => [ [],
252 [ @XFORMS_ATTRIBUTE_SINGLENODE,
253 @XFORMS_ATTRIBUTE_LINKING ],
254 1,
255 [],
256 [ "xforms:output", "##OTHER##"] ],
257 "xforms:mediatype" => [ [],
258 [ @XFORMS_ATTRIBUTE_SINGLENODE ],
259 0,
260 [],
261 [] ],
262 "xforms:value" => [ [],
263 [ @XFORMS_ATTRIBUTE_SINGLENODE ],
264 1,
265 [],
266 [ "##ANY##" ] ],
267 "xforms:group" => [ [],
268 [ @XFORMS_ATTRIBUTE_SINGLENODE ],
269 0,
270 [],
271 [ "xforms:label", "xforms:group",
272 "xforms:switch", "xforms:repeat",
273 @XFORMS_CONTROL, "##OTHER##" ] ],
274 "xforms:switch" => [ [],
275 [],
276 0,
277 [ "xforms:case"],
278 [] ],
279 "xforms:repeat" => [ [],
280 [ "startindex", "number" ],
281 0,
282 [],
283 [ "xforms:group", "xforms:repeat",
284 @XFORMS_CONTROL, "##OTHER##" ] ],
285 "xforms:case" => [ [ "id" ],
286 [ "selected" ],
287 0,
288 [],
289 [ @XFORMS_CONTROL,
290 @XFORMS_USERINTERFACE,
291 "##OTHER##" ] ],
292 "xforms:toggle" => [ [],
293 [ @XFORMS_ATTRIBUTE_EVENT,
294 "case" ],
295 0,
296 [],
297 [] ],
298 "xforms:action" => [ [],
299 [ @XFORMS_ATTRIBUTE_EVENT ],
300 0,
301 [],
302 [ @XFORMS_ACTION ] ],
303 "xforms:dispatch" => [ [ "name", "target" ],
304 [ @XFORMS_ATTRIBUTE_EVENT,
305 "bubbles", "cancelable" ],
306 0,
307 [],
308 [] ],
309 "xforms:rebuild" => [ [],
310 [ @XFORMS_ATTRIBUTE_EVENT,
311 "model" ],
312 0,
313 [],
314 [] ],
315 "xforms:recalculate" => [ [],
316 [ @XFORMS_ATTRIBUTE_EVENT,
317 "model" ],
318 0,
319 [],
320 [] ],
321 "xforms:revalidate" => [ [],
322 [ @XFORMS_ATTRIBUTE_EVENT,
323 "model" ],
324 0,
325 [],
326 [] ],
327 "xforms:refresh" => [ [],
328 [ @XFORMS_ATTRIBUTE_EVENT,
329 "model" ],
330 0,
331 [],
332 [] ],
333 "xforms:setfocus" => [ [ "control" ],
334 [ @XFORMS_ATTRIBUTE_EVENT ],
335 0,
336 [],
337 [] ],
338 "xforms:load" => [ [ "src" ],
339 [ @XFORMS_ATTRIBUTE_EVENT,
340 @XFORMS_ATTRIBUTE_SINGLENODE,
341 @XFORMS_ATTRIBUTE_LINKING,
342 "show", "src" ],
343 0,
344 [],
345 [] ],
346 "xforms:setvalue" => [ [],
347 [ @XFORMS_ATTRIBUTE_EVENT,
348 @XFORMS_ATTRIBUTE_SINGLENODE,
349 "value" ],
350 1,
351 [],
352 [] ],
353 "xforms:send" => [ [],
354 [ @XFORMS_ATTRIBUTE_EVENT,
355 "submission" ],
356 0,
357 [],
358 [] ],
359 "xforms:reset" => [ [],
360 [ @XFORMS_ATTRIBUTE_EVENT,
361 "model" ],
362 0,
363 [],
364 [] ],
365 "xforms:message" => [ [ "level" ],
366 [ @XFORMS_ATTRIBUTE_EVENT,
367 @XFORMS_ATTRIBUTE_SINGLENODE,
368 @XFORMS_ATTRIBUTE_LINKING ],
369 1,
370 [],
371 [] ],
372 );
373  
374  
375  
376 ##==================================================================##
377 ## Constructor(s)/Deconstructor(s) ##
378 ##==================================================================##
379  
380 ##
381 ## None.
382 ##
383  
384 ##==================================================================##
385 ## Method(s) ##
386 ##==================================================================##
387  
388 ##
389 ## None.
390 ##
391  
392 ##==================================================================##
393 ## Function(s) ##
394 ##==================================================================##
395  
396 ##
397 ## None.
398 ##
399  
400 ##==================================================================##
401 ## Internal Function(s) ##
402 ##==================================================================##
403  
404 ##----------------------------------------------##
405 ## __xforms_attribute ##
406 ##----------------------------------------------##
407 ## Convience function to set attributes on a ##
408 ## XForms element. ##
409 ##----------------------------------------------##
410 sub __xforms_attribute ($$)
411 9 ▶{
Subroutine __xforms_attribute: called CC=8 SCAR=27.7
412 9 my( $element, $attributes ) = @_;
413  
414 9 my $type = $element->nodeName;
415  
416 ## Look to make sure that we set all of the required elements.
417 9 foreach( @{ $XFORMS_SCHEMA{$type}->[0] } )
418 {
419 2 ▶ if( defined( $attributes->{$_} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attributes->{$_}) { } 2 0 2
420 {
421 2 $element->setAttribute( $_, $attributes->{$_} );
422 2 delete( $attributes->{$_} );
423 }
424 else
425 {
426 0 croak( qq|Error: $type element is missing the required attribute | .
427 qq|'$_'| );
428 }
429 }
430  
431 ## Make sure we set any optional elements defined as part of the
432 ## specification.
433 9 foreach( @{ $XFORMS_SCHEMA{$type}->[1] }, "id", "nodeset", "type",
434 "readonly", "calculate", "required", "relevant",
435 "constraint", "maxOccurs" )
436 {
437 121 ▶ if( defined( $attributes->{$_} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attributes->{$_}) 0 121 121
438 {
439 0 $element->setAttribute( $_, $attributes->{$_} );
440 0 delete( $attributes->{$_} );
441 }
442 }
443  
444 ## Finally - all XForms elements are allowed to have attributes existing
445 ## outside the specification, but they must be in another namespace.
446 9 foreach( keys( %{ $attributes } ) )
447 {
448 ## We need to ensure we grabbed a prefix from the attribute name.
449 0 ▶ if( $_ !~ /:/ )
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ =~ /:/) 0 0 0
450 {
451 0 croak( qq|Error: This element can only accept attributes not |,
452 qq|defined by the XForms specification when they exist |,
453 qq|in another namespace. The attribute $_ is not |,
454 qq|recognized to be part of the XForms specification| );
455 }
456  
457 ## Pull the prefix of the name space from the attribute name.
458 0 $_ =~ /^([a-z]+):/;
459  
460 ## Check to ensure the name space is recognized.
461 0 ▶ if( !defined( $XFORMS_NAMESPACE{ $1 } ) )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $XML::XForms::Generator::Common::XFORMS_NAMESPACE{$1}) 0 0 0
462 {
463 0 croak( qq|Error: The namespace $1 on the foriegn attribute $_ |,
464 qq|is not recognized. Attempt to add its definition via |,
465 qq|xforms_add_namespace call and retry| );
466 }
467  
468 ## Add the attribute with the namespace attached.
469 $element->setAttributeNS( $XFORMS_NAMESPACE{ $1 },
470 $_,
471 0 $attributes->{$_} );
472 }
473  
474 9 return;
475 }
476  
477 ##----------------------------------------------##
478 ## __xforms_children ##
479 ##----------------------------------------------##
480 ## Convience function to append children ##
481 ## correctly to a XForms element. ##
482 ##----------------------------------------------##
483 sub __xforms_children ($@)
484 9 ▶{
Subroutine __xforms_children: called CC=31 SCAR=46.6
485 9 my( $element, @children ) = @_;
486  
487 9 my $type = $element->nodeName;
488
489 ## We first do a check to see if we have all of the required children
490 ## of an element.
491 9 foreach( @{ $XFORMS_SCHEMA{$type}->[3] } )
492 {
493 3 my $status = 1;
494
495 3 foreach my $child ( @children )
496 {
497 4 ▶ if( ( ref( $child ) ) && ( ref( $child ) eq "ARRAY" ) )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $child and ref $child eq 'ARRAY') { } 4 0 4
elsif (ref $child and $child->isa('XML::LibXML::Node')) { } 0 0 0
Condition33%1/3
ref $child and ref $child eq "ARRAY"
!ll&&!rl&&r
004
MC/DC0%0/2
ref $child and ref $child eq "ARRAY"
ref $child ref $child eq "ARRAY"
Truth table33%1/3
A and B
A= ref $childB= ref $child eq "ARRAY"
ABresult
0X0
100
111
498 {
499 4 my $name = $child->[0];
500  
501 4 ▶ if( ( $_ eq $name ) || ( $_ eq "xforms:$name" ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $name or $_ eq "xforms:$name") 3 1 4
Condition66%2/3
$_ eq $name or $_ eq "xforms:$name"
l!l&&r!l&&!r
031
MC/DC50%1/2
$_ eq $name or $_ eq "xforms:$name"
$_ eq $name $_ eq "xforms:$name"
Truth table66%2/3
A or B
A= $_ eq $nameB= $_ eq "xforms:$name"
ABresult
1X1
011
000
502 {
503 3 $status = 0;
504 }
505 }
506 ▶ elsif( ( ref( $child ) ) && ( $child->isa( "XML::LibXML::Node" ) ) )
Condition0%0/3
ref $child and $child->isa("XML::LibXML::Node")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $child and $child->isa("XML::LibXML::Node")
ref $child $child->isa("XML::LibXML::Node")
Truth table0%0/3
A and B
A= ref $childB= $child->isa("XML::LibXML::Node")
ABresult
0X0
100
111
507 {
508 0 my $name = $child->nodeName;
509
510 0 ▶ if( ( $_ eq $name ) || ( $_ eq "xforms:$name" ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq $name or $_ eq "xforms:$name") 0 0 0
Condition0%0/3
$_ eq $name or $_ eq "xforms:$name"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq $name or $_ eq "xforms:$name"
$_ eq $name $_ eq "xforms:$name"
Truth table0%0/3
A or B
A= $_ eq $nameB= $_ eq "xforms:$name"
ABresult
1X1
011
000
511 {
512 0 $status = 0;
513 }
514 }
515 }
516  
517 3 ▶ if( $_ eq "##ANYDOM##" )
Branch: 1 branch
BranchTrueFalseTotal
if ($_ eq "##ANYDOM##") 0 3 3
518 {
519 0 ▶ if( ( scalar( @children ) == 1 ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @children == 1 and ref $children[0] and $children[0]->isa('XML::LibXML::Node')) { } 0 0 0
Condition0%0/6
scalar @children == 1 and ref $children[0] and $children[0]->isa("XML::LibXML::Node")
!ll&&!rl&&r
000
scalar @children == 1 and ref $children[0]
!ll&&!rl&&r
000
MC/DC0%0/3
scalar @children == 1 and ref $children[0] and $children[0]->isa("XML::LibXML::Node")
scalar @children == 1 ref $children[0] $children[0]->isa("XML::LibXML::Node")
Truth table0%0/4
A and B and C
A= scalar @children == 1B= ref $children[0]C= $children[0]->isa("XML::LibXML::Node")
ABCresult
0XX0
10X0
1100
1111
520 ( ref( $children[0] ) ) &&
521 ( $children[0]->isa( "XML::LibXML::Node" ) ) )
522 {
523 ## We need to ensure that the next test is passed because
524 ## this node is golden.
525 0 $status = 0;
526 }
527 else
528 {
529 0 croak( qq|Error: $type element requires that a single |,
530 qq|DOM tree be its child element.| );
531 }
532 }
533  
534 3 ▶ if( $status )
Branch: 1 branch
BranchTrueFalseTotal
if ($status) 0 3 3
535 {
536 0 croak( qq|Error: $type element is missing required child |,
537 qq|element '$_'| );
538 }
539 }
540  
541 ## Loop through each of the children and determine what we need to do
542 ## with them.
543 9 foreach my $child ( @children )
544 {
545 8 ▶ if( ( defined( $child ) ) && ( $child ne "" ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $child and $child ne "") 8 0 8
Condition33%1/3
defined $child and $child ne ""
!ll&&!rl&&r
008
MC/DC0%0/2
defined $child and $child ne ""
defined $child $child ne ""
Truth table33%1/3
A and B
A= defined $childB= $child ne ""
ABresult
0X0
100
111
546 {
547 8 ▶ if( ( ref( $child ) ) && ( ref( $child ) eq "ARRAY" ) )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $child and ref $child eq 'ARRAY') { } 4 4 8
elsif (ref $child and $child->isa('XML::LibXML::Node')) { } 1 3 4
Condition100%3/3
ref $child and ref $child eq "ARRAY"
!ll&&!rl&&r
314
MC/DC100%2/2
ref $child and ref $child eq "ARRAY"
ref $child ref $child eq "ARRAY"
Truth table100%3/3
A and B
A= ref $childB= ref $child eq "ARRAY"
ABresult
0X0
100
111
548 {
549 4 my $name = "append" . ucfirst( lc( shift( @{ $child } ) ) );
550 #my $name = ucfirst( lc( shift( @{ $child } ) ) );
551 4 my $attr = shift( @{ $child } );
552 4 my @chld = @{ $child };
553 ## I need to benchmark the two methods and figure out which
554 ## is faster. I think the eval will be slower though.
555 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
556 4 $element->$name( $attr, @chld );
557 5 ▶ use strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
558 #eval "\$element->append$name( \$attr, \@chld );";
559 #print "$@\n" if( $@ );
560 }
561 ▶ elsif( ( ref( $child ) ) && ( $child->isa( "XML::LibXML::Node" ) ) )
Condition66%2/3
ref $child and $child->isa("XML::LibXML::Node")
!ll&&!rl&&r
301
MC/DC50%1/2
ref $child and $child->isa("XML::LibXML::Node")
ref $child $child->isa("XML::LibXML::Node")
Truth table66%2/3
A and B
A= ref $childB= $child->isa("XML::LibXML::Node")
ABresult
0X0
100
111
562 {
563 1 my $name = $child->nodeName;
564  
565 1 foreach( @{ $XFORMS_SCHEMA{$type}->[3] },
566 1 @{ $XFORMS_SCHEMA{$type}->[4] } )
567 {
568 1 ▶ if( ( $_ eq "##ANY##" ) ||
Branch: 2 branches
BranchTrueFalseTotal
if ($_ eq '##ANY##' or $_ eq $name or $_ eq "xforms:$name" or $_ eq '##ANYDOM##') { } 0 1 1
elsif ($_ eq '##OTHER##' and not $name =~ /xforms:/) { } 1 0 1
Condition33%3/9
$_ eq "##ANY##" or $_ eq $name or $_ eq "xforms:$name" or $_ eq "##ANYDOM##"
l!l&&r!l&&!r
001
$_ eq "##ANY##" or $_ eq $name or $_ eq "xforms:$name"
l!l&&r!l&&!r
001
$_ eq "##ANY##" or $_ eq $name
l!l&&r!l&&!r
001
MC/DC0%0/4
$_ eq "##ANY##" or $_ eq $name or $_ eq "xforms:$name" or $_ eq "##ANYDOM##"
$_ eq "##ANY##" $_ eq $name $_ eq "xforms:$name" $_ eq "##ANYDOM##"
Truth table20%1/5
A or B or C or D
A= $_ eq "##ANY##"B= $_ eq $nameC= $_ eq "xforms:$name"D= $_ eq "##ANYDOM##"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
569 ( $_ eq $name ) ||
570 ( $_ eq "xforms:$name" ) ||
571 ( $_ eq "##ANYDOM##" ) )
572 {
573 0 $element->appendChild( $child );
574 }
575 ▶ elsif( ( $_ eq "##OTHER##" ) && ( $name !~ /xforms:/ ) )
Condition33%1/3
$_ eq "##OTHER##" and not $name =~ /xforms:/
!ll&&!rl&&r
001
MC/DC0%0/2
$_ eq "##OTHER##" and not $name =~ /xforms:/
$_ eq "##OTHER##" not $name =~ /xforms:/
Truth table33%1/3
A and not(B)
A= $_ eq "##OTHER##"B= not $name =~ /xforms:/
ABresult
0X0
100
111
576 {
577 1 $element->appendChild( $child );
578 }
579 }
580 }
581 else
582 {
583 3 ▶ if( $XFORMS_SCHEMA{$type}->[2] == 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($XML::XForms::Generator::Common::XFORMS_SCHEMA{$type}[2] == 1) 3 0 3
584 {
585 3 $element->appendText( $child );
586 }
587 }
588 }
589 }
590  
591 9 return;
592 }
593  
594 ##==================================================================##
595 ## End of Code ##
596 ##==================================================================##
597 5 1;
598  
599 ##==================================================================##
600 ## Plain Old Documentation (POD) ##
601 ##==================================================================##
602  
603 __END__
« Generator/Model.pm ↑ Summary Generator/UserInterface.pm »