Schema/Parser.pm

filter: Statementstmt 97.3% 146 / 150 Branchbran 80.4% 74 / 92 Conditioncond 87.8% 65 / 74 MC/DCmcdc 67.5% 25 / 37 Subroutinesub 100% 7 / 7 Podpod 66.6% 2 / 3 totaltotal 87.8% 319 / 363 CC 74 SCAR 37.6
CC
74
Cov
90%
start_element
56.3
end_element
21.3
new
2.1
CRAP 43.0
↑ Summary Schema/SimpleType.pm »
1 package XML::Validator::Schema::Parser;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 XML::Validator::Schema::Parser - XML Schema Document Parser
8  
9 =head1 DESCRIPTION
10  
11 This is an internal module used by XML::Validator::Schema to parse XML
12 Schema documents.
13  
14 =cut
15  
16 5 ▶use base 'XML::SAX::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use XML::Validator::Schema::Util qw(_attr _err);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 51 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
20 51 my $pkg = shift;
21 0 ▶ my $opt = (@_ == 1) ? { %{shift()} } : {@_};
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 51 51
22 51 my $self = bless $opt, $pkg;
23  
24 # start with a dummy root node and an empty stack of elements
25 51 $self->{node_stack} = $self->{schema}{node_stack};
26  
27 51 return $self;
28 }
29  
30 604 ▶sub start_element {
Subroutine start_element: called CC=53 SCAR=40.3
Pod documented
31 604 my ($self, $data) = @_;
32 604 my $node_stack = $self->{node_stack};
33 604 ▶ my $mother = @$node_stack ? $node_stack->[-1] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@$node_stack ? : 553 51 604
34 604 my $name = $data->{LocalName};
35  
36 # make sure schema comes first
37 604 ▶ _err("Root element must be <schema>, fount <$name> instead.")
Branch: 1 branch
BranchTrueFalseTotal
if @$node_stack == 0 and $name ne "schema" 0 604 604
Condition66%2/3
@$node_stack == 0 and $name ne "schema"
!ll&&!rl&&r
553510
MC/DC0%0/2
@$node_stack == 0 and $name ne "schema"
@$node_stack == 0 $name ne "schema"
Truth table66%2/3
A and B
A= @$node_stack == 0B= $name ne "schema"
ABresult
0X0
100
111
38 if @$node_stack == 0 and $name ne 'schema';
39
40 # starting up?
41 604 ▶ if ($name eq 'schema') {
Branch: 12 branches
BranchTrueFalseTotal
if ($name eq 'schema') { } 51 553 604
elsif ($name eq 'element') { } 242 311 553
elsif ($name eq 'attribute') { } 27 284 311
elsif ($name eq 'simpleContent') { } 9 275 284
elsif ($name eq 'extension') { } 9 266 275
elsif ($name eq 'simpleType') { } 42 224 266
elsif ($name eq 'restriction') { } 39 185 224
elsif ($name eq 'union') { } 3 182 185
elsif ($name eq 'whiteSpace' or $name eq 'pattern' or $name eq 'enumeration' or $name eq 'length' or $name eq 'minLength' or $name eq 'maxLength' or $name eq 'minInclusive' or $name eq 'minExclusive' or $name eq 'maxInclusive' or $name eq 'maxExclusive' or $name eq 'totalDigits' or $name eq 'fractionDigits') { } 59 123 182
elsif ($name eq 'complexType') { } 63 60 123
elsif ($name eq 'sequence' or $name eq 'choice' or $name eq 'all') { } 50 10 60
elsif ($name eq 'annotation' or $name eq 'documentation') { } 10 0 10
42 51 my $node = XML::Validator::Schema::RootNode->new;
43 51 $node->name('<<<ROOT>>>');
44 51 push(@$node_stack, $node);
45  
46 # make sure elementFormDefault and attributeFormDefault are
47 # 'unqualified' if declared since that's all we're up to
48 51 for (qw(elementFormDefault attributeFormDefault)) {
49 101 my $a = _attr($data, $_);
50 101 ▶ _err("$_ in <schema> must be 'unqualified', ".
Branch: 1 branch
BranchTrueFalseTotal
if $a and $a ne "unqualified" 1 100 101
Condition100%3/3
$a and $a ne "unqualified"
!ll&&!rl&&r
90101
MC/DC100%2/2
$a and $a ne "unqualified"
$a $a ne "unqualified"
Truth table100%3/3
A and B
A= $aB= $a ne "unqualified"
ABresult
0X0
100
111
51 "'qualified' is not supported.")
52 if $a and $a ne 'unqualified';
53 }
54  
55 # ignoring targetSchema intentionally. With both Defaults
56 # unqualified there isn't much point looking at it.
57 }
58  
59 # handle element declaration
60 elsif ($name eq 'element') {
61 242 my $node;
62 242 ▶ if (_attr($data, 'ref')) {
Branch: 1 branch
BranchTrueFalseTotal
if (_attr($data, 'ref')) { } 43 199 242
63 43 $node = XML::Validator::Schema::ElementRefNode->parse($data);
64 } else {
65 # create a new node for the element
66 199 $node = XML::Validator::Schema::ElementNode->parse($data);
67 }
68  
69 # add to current node's daughter list and become the current node
70 242 $mother->add_daughter($node);
71 242 push @$node_stack, $node;
72 }
73  
74 elsif ($name eq 'attribute') {
75 # check anonymous/named constraints
76 27 my $name = _attr($data, 'name');
77 27 ▶ _err("Anonymous global simpleType not allowed.")
Branch: 1 branch
BranchTrueFalseTotal
if not $name and $mother->is_root 0 27 27
Condition66%2/3
not $name and $mother->is_root
!ll&&!rl&&r
2610
MC/DC0%0/2
not $name and $mother->is_root
not $name $mother->is_root
Truth table66%2/3
not(A) and B
A= not $nameB= $mother->is_root
ABresult
0X0
100
111
78 if not $name and $mother->is_root;
79  
80 # parse it into an AttributeNode and tell Mom about it
81 27 my $node = XML::Validator::Schema::AttributeNode->parse($data);
82 27 $mother->add_daughter($node);
83 27 push @$node_stack, $node;
84 }
85  
86 elsif ($name eq 'simpleContent') {
87 _err("Found simpleContent outside a complexType.")
88 unless $mother->{is_complex} or
89 9 ▶ $mother->isa('XML::Validator::Schema::ComplexTypeNode');
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->{"is_complex"} or $mother->isa("XML::Validator::Schema::ComplexTypeNode") 0 9 9
Condition33%1/3
$mother->{"is_complex"} or $mother->isa("XML::Validator::Schema::ComplexTypeNode")
l!l&&r!l&&!r
900
MC/DC0%0/2
$mother->{"is_complex"} or $mother->isa("XML::Validator::Schema::ComplexTypeNode")
$mother->{"is_complex"} $mother->isa("XML::Validator::Schema::ComplexTypeNode")
Truth table33%1/3
A or B
A= $mother->{"is_complex"}B= $mother->isa("XML::Validator::Schema::ComplexTypeNode")
ABresult
1X1
011
000
90  
91 9 $mother->{simple_content} = 1;
92 }
93  
94 elsif ($name eq 'extension') {
95 _err("Found illegal <extension> outside simpleContent.")
96 9 ▶ unless $mother->{simple_content};
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->{"simple_content"} 0 9 9
97  
98 # extract simpleType from base
99 9 my $base = _attr($data, 'base');
100 9 ▶ _err("Found <extension> without required 'base' attribute.")
Branch: 1 branch
BranchTrueFalseTotal
unless $base 0 9 9
101 unless $base;
102 9 $mother->{type_name} = $base;
103 9 $mother->{unresolved_type} = 1;
104 }
105  
106 elsif ($name eq 'simpleType') {
107 42 my $name = _attr($data, 'name');
108 42 ▶ if ($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) { } 25 17 42
109 25 ▶ _err("Named simpleType must be global.")
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->is_root 0 25 25
110 unless $mother->is_root;
111  
112 # this is a named type, parse it into an SimpleTypeNode
113 # and tell Mom about it
114 25 my $node = XML::Validator::Schema::SimpleTypeNode->parse($data);
115 25 $mother->add_daughter($node);
116 25 push @$node_stack, $node;
117  
118 } else {
119 17 ▶ _err("Anonymous global simpleType not allowed.")
Branch: 1 branch
BranchTrueFalseTotal
if $mother->is_root 0 17 17
120 if $mother->is_root;
121
122 _err("Found <simpleType> illegally combined with <complexType>.")
123 17 ▶ if $mother->{is_complex};
Branch: 1 branch
BranchTrueFalseTotal
if $mother->{"is_complex"} 0 17 17
124  
125 # this is a named type, parse it into a SimpleTypeNode
126 # and tell Mom about it
127 17 my $node = XML::Validator::Schema::SimpleTypeNode->parse($data);
128 17 $mother->add_daughter($node);
129 17 push @$node_stack, $node;
130  
131 }
132 }
133
134 elsif ($name eq 'restriction') {
135 39 ▶ _err("Found <restriction> outside a <simpleType> definition.")
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->isa("XML::Validator::Schema::SimpleTypeNode") 0 39 39
136 unless $mother->isa('XML::Validator::Schema::SimpleTypeNode');
137 39 $mother->parse_restriction($data);
138 }
139  
140 elsif ( $name eq 'union' ) {
141 3 ▶ _err("Found <union> outside a <simpleType> definition.")
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->isa("XML::Validator::Schema::SimpleTypeNode") 0 3 3
142 unless $mother->isa('XML::Validator::Schema::SimpleTypeNode');
143 # The union might just have a 'memberTypes' attribute or it might
144 # contain a bunch of inline anonymous simpleTypes.
145  
146 3 my $node = XML::Validator::Schema::ModelNode->parse($data);
147 3 my $gran = $mother->{mother};
148  
149 3 $mother->add_daughter($node);
150  
151 # At parse time, the only node that gets inspected is the
152 # grandmother node, so let's load everything required at runtime
153 # onto that
154 3 $mother->{got_union} = 1;
155 3 $node->{is_union} = 1;
156 3 $node->{next_instance} = 0;
157 3 $gran->{members} = []; # array of member ElementNodes
158  
159 3 ▶ if ( _attr($data,'memberTypes') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_attr($data, "memberTypes")) 1 2 3
160 # Stuff stolen pretty indiscriminately from SimpleTypeNode
161 1 my @mts = split(/ +/,_attr($data,'memberTypes'));
162 1 foreach my $m ( @mts ) {
163 2 my $mbr = XML::Validator::Schema::ElementNode->new();
164 2 my $mt = XML::Validator::Schema::SimpleTypeNode->new();
165 2 $mt->{base} = $m;
166 # Why mother->root? well any old valid ref to root will do and
167 # I can't find one anywhere else...
168 2 my $base = $mother->root->{type_library}->find(name => $mt->{base});
169 2 my $type = $base->derive();
170 2 $mbr->{type} = $type;
171 2 $mbr->add_daughter($mt);
172 2 push(@{$gran->{members}},$mbr);
173 2 $node->{next_instance} ++;
174 }
175 }
176  
177 3 $node ->{name} = $gran->{name} . '__';
178 3 push @$node_stack,$node;
179  
180 }
181  
182 ▶ elsif ($name eq 'whiteSpace' or
Condition96%32/33
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive" or $name eq "minExclusive" or $name eq "maxInclusive" or $name eq "maxExclusive" or $name eq "totalDigits" or $name eq "fractionDigits"
l!l&&r!l&&!r
554123
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive" or $name eq "minExclusive" or $name eq "maxInclusive" or $name eq "maxExclusive" or $name eq "totalDigits"
l!l&&r!l&&!r
514127
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive" or $name eq "minExclusive" or $name eq "maxInclusive" or $name eq "maxExclusive"
l!l&&r!l&&!r
501131
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive" or $name eq "minExclusive" or $name eq "maxInclusive"
l!l&&r!l&&!r
482132
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive" or $name eq "minExclusive"
l!l&&r!l&&!r
471134
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive"
l!l&&r!l&&!r
425135
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength"
l!l&&r!l&&!r
357140
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength"
l!l&&r!l&&!r
2411147
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length"
l!l&&r!l&&!r
195158
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration"
l!l&&r!l&&!r
514163
$name eq "whiteSpace" or $name eq "pattern"
l!l&&r!l&&!r
05177
MC/DC91%11/12
$name eq "whiteSpace" or $name eq "pattern" or $name eq "enumeration" or $name eq "length" or $name eq "minLength" or $name eq "maxLength" or $name eq "minInclusive" or $name eq "minExclusive" or $name eq "maxInclusive" or $name eq "maxExclusive" or $name eq "totalDigits" or $name eq "fractionDigits"
$name eq "whiteSpace" $name eq "pattern" $name eq "enumeration" $name eq "length" $name eq "minLength" $name eq "maxLength" $name eq "minInclusive" $name eq "minExclusive" $name eq "maxInclusive" $name eq "maxExclusive" $name eq "totalDigits" $name eq "fractionDigits"
Truth table92%12/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $name eq "whiteSpace"B= $name eq "pattern"C= $name eq "enumeration"D= $name eq "length"E= $name eq "minLength"F= $name eq "maxLength"G= $name eq "minInclusive"H= $name eq "minExclusive"I= $name eq "maxInclusive"J= $name eq "maxExclusive"K= $name eq "totalDigits"L= $name eq "fractionDigits"
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
183 $name eq 'pattern' or
184 $name eq 'enumeration' or
185 $name eq 'length' or
186 $name eq 'minLength' or
187 $name eq 'maxLength' or
188 $name eq 'minInclusive' or
189 $name eq 'minExclusive' or
190 $name eq 'maxInclusive' or
191 $name eq 'maxExclusive' or
192 $name eq 'totalDigits' or
193 $name eq 'fractionDigits') {
194 59 ▶ _err("Found <$name> outside a <simpleType> definition.")
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->isa("XML::Validator::Schema::SimpleTypeNode") 0 59 59
195 unless $mother->isa('XML::Validator::Schema::SimpleTypeNode');
196 59 $mother->parse_facet($data);
197 }
198  
199 elsif ($name eq 'complexType') {
200 63 my $name = _attr($data, 'name');
201 63 ▶ if ($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) { } 8 55 63
202 8 ▶ _err("Named complexType must be global.")
Branch: 1 branch
BranchTrueFalseTotal
unless $mother->is_root 0 8 8
203 unless $mother->is_root;
204  
205 # this is a named type, parse it into an ComplexTypeNode
206 # and tell Mom about it
207 8 my $node = XML::Validator::Schema::ComplexTypeNode->parse($data);
208 8 $mother->add_daughter($node);
209 8 push @$node_stack, $node;
210  
211
212 } else {
213 55 ▶ _err("Anonymous global complexType not allowed.")
Branch: 1 branch
BranchTrueFalseTotal
if $mother->is_root 0 55 55
214 if $mother->is_root;
215  
216 # anonymous complexTypes are just noted and passed on
217 55 $mother->{is_complex} = 1;
218 }
219
220 }
221  
222 ▶ elsif ($name eq 'sequence' or $name eq 'choice' or $name eq 'all') {
Condition100%6/6
$name eq "sequence" or $name eq "choice" or $name eq "all"
l!l&&r!l&&!r
45510
$name eq "sequence" or $name eq "choice"
l!l&&r!l&&!r
41415
MC/DC100%3/3
$name eq "sequence" or $name eq "choice" or $name eq "all"
$name eq "sequence" $name eq "choice" $name eq "all"
Truth table100%4/4
A or B or C
A= $name eq "sequence"B= $name eq "choice"C= $name eq "all"
ABCresult
1XX1
01X1
0011
0000
223 # create a new node for the model
224 50 my $node = XML::Validator::Schema::ModelNode->parse($data);
225
226 # add to current node's daughter list and become the current node
227 50 $mother->add_daughter($node);
228 50 push @$node_stack, $node;
229  
230 # all needs special support due to the restrictions on its use
231 50 ▶ $mother->{is_all} = 1 if $name eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "all" 5 45 50
232 }
233  
234 ▶ elsif ($name eq 'annotation' or $name eq 'documentation') {
Condition66%2/3
$name eq "annotation" or $name eq "documentation"
l!l&&r!l&&!r
550
MC/DC0%0/2
$name eq "annotation" or $name eq "documentation"
$name eq "annotation" $name eq "documentation"
Truth table66%2/3
A or B
A= $name eq "annotation"B= $name eq "documentation"
ABresult
1X1
011
000
235 # skip
236 }
237  
238 else {
239 # getting here is bad news
240 0 _err("Unrecognized element '<$name>' found.");
241 }
242 }
243  
244 575 ▶sub end_element {
Subroutine end_element: called CC=21 SCAR=30.6
Pod documented
245 575 my ($self, $data) = @_;
246 575 my $node_stack = $self->{node_stack};
247 575 my $node = $node_stack->[-1];
248 575 my $name = $data->{LocalName};
249  
250 # all done?
251 575 ▶ if ($name eq 'schema') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "schema") 39 536 575
252 39 ▶ croak("Module done broke, man. That element stack ain't empty!")
Branch: 1 branch
BranchTrueFalseTotal
unless @$node_stack == 1 0 39 39
253 unless @$node_stack == 1;
254  
255 # finish up
256 39 $node_stack->[-1]->compile();
257  
258 38 return;
259 }
260  
261 # end of an element?
262 536 ▶ if ($name eq 'element') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "element") 241 295 536
263 241 $node->compile();
264 240 pop @$node_stack;
265 240 return;
266 }
267  
268 # end of a model?
269 295 ▶ if ($name eq 'sequence' or $name eq 'choice' or $name eq 'all') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "sequence" or $name eq "choice" or $name eq "all") 50 245 295
Condition100%6/6
$name eq "sequence" or $name eq "choice" or $name eq "all"
l!l&&r!l&&!r
455245
$name eq "sequence" or $name eq "choice"
l!l&&r!l&&!r
414250
MC/DC100%3/3
$name eq "sequence" or $name eq "choice" or $name eq "all"
$name eq "sequence" $name eq "choice" $name eq "all"
Truth table100%4/4
A or B or C
A= $name eq "sequence"B= $name eq "choice"C= $name eq "all"
ABCresult
1XX1
01X1
0011
0000
270 50 pop @$node_stack;
271 50 return;
272 }
273  
274 # end of a named complexType?
275 245 ▶ if ($name eq 'complexType' and
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "complexType" and $node->isa("XML::Validator::Schema::ComplexTypeNode")) 8 237 245
Condition100%3/3
$name eq "complexType" and $node->isa("XML::Validator::Schema::ComplexTypeNode")
!ll&&!rl&&r
182558
MC/DC100%2/2
$name eq "complexType" and $node->isa("XML::Validator::Schema::ComplexTypeNode")
$name eq "complexType" $node->isa("XML::Validator::Schema::ComplexTypeNode")
Truth table100%3/3
A and B
A= $name eq "complexType"B= $node->isa("XML::Validator::Schema::ComplexTypeNode")
ABresult
0X0
100
111
276 $node->isa('XML::Validator::Schema::ComplexTypeNode')) {
277 8 $node->compile;
278  
279 8 $node->mother->remove_daughter($node);
280 8 pop @{$self->{node_stack}};
281 8 return;
282 }
283  
284 # end of a union?
285 237 ▶ if ( $name eq 'union' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "union") 3 234 237
286 # Fail if it has no members
287 3 ▶ if ( $node->{is_union} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{'is_union'}) { } 3 0 3
288 3 ▶ if ( not defined($node->{next_instance}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $node->{'next_instance'}) { } 0 3 3
289 0 die "Node is_union but has no next_instance!";
290 }else {
291 3 ▶ if ( $node->{next_instance} == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"next_instance"} == 0) 1 2 3
292 1 _err("Union defined with no members");
293 }
294 }
295 } else {
296 0 die "Node is a a union but not is_union - something is wrong.";
297 }
298 2 pop @$node_stack;
299 2 return;
300 }
301  
302 # end of named simpleType?
303 234 ▶ if ( $name eq 'simpleType' and
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "simpleType" and $node->isa("XML::Validator::Schema::SimpleTypeNode")) 36 198 234
Condition66%2/3
$name eq "simpleType" and $node->isa("XML::Validator::Schema::SimpleTypeNode")
!ll&&!rl&&r
198036
MC/DC50%1/2
$name eq "simpleType" and $node->isa("XML::Validator::Schema::SimpleTypeNode")
$name eq "simpleType" $node->isa("XML::Validator::Schema::SimpleTypeNode")
Truth table66%2/3
A and B
A= $name eq "simpleType"B= $node->isa("XML::Validator::Schema::SimpleTypeNode")
ABresult
0X0
100
111
304 $node->isa('XML::Validator::Schema::SimpleTypeNode')
305 )
306 {
307 36 $node->check_constraints();
308 33 my $type = $node->compile();
309 # If the node doesn't have a name, set parent's type
310 # to be the type of this node
311 32 ▶ $node->mother->{type} = $type unless $node->{name};
Branch: 1 branch
BranchTrueFalseTotal
unless $node->{"name"} 14 18 32
312 32 $node->mother->remove_daughter($node);
313 32 pop @{$self->{node_stack}};
314 32 return;
315 }
316  
317 # end of an attribute?
318 198 ▶ if ($name eq 'attribute' and
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "attribute" and $node->isa("XML::Validator::Schema::AttributeNode")) 27 171 198
Condition66%2/3
$name eq "attribute" and $node->isa("XML::Validator::Schema::AttributeNode")
!ll&&!rl&&r
171027
MC/DC50%1/2
$name eq "attribute" and $node->isa("XML::Validator::Schema::AttributeNode")
$name eq "attribute" $node->isa("XML::Validator::Schema::AttributeNode")
Truth table66%2/3
A and B
A= $name eq "attribute"B= $node->isa("XML::Validator::Schema::AttributeNode")
ABresult
0X0
100
111
319 $node->isa('XML::Validator::Schema::AttributeNode')) {
320 27 my $attr = $node->compile();
321 27 my $mother = $node->mother();
322 27 my $name = $attr->{name};
323  
324 27 ▶ if ($name and $mother->is_root) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $mother->is_root) { } 1 26 27
Condition66%2/3
$name and $mother->is_root
!ll&&!rl&&r
0261
MC/DC50%1/2
$name and $mother->is_root
$name $mother->is_root
Truth table66%2/3
A and B
A= $nameB= $mother->is_root
ABresult
0X0
100
111
325 # named attribute in the root gets added to the attribute library
326 1 $mother->{attribute_library}->add(name => $name,
327 obj => $attr);
328 } else {
329 # attribute in an element goes on the attr array
330 26 ▶ push @{$mother->{attr} ||= []}, $attr;
Condition100%2/2
$mother->{"attr"} ||= []
l!l
917
MC/DC100%1/1
$mother->{"attr"} ||= []
$mother->{"attr"}
Truth table100%2/2
A
A= $mother->{"attr"}
Aresult
11
00
331 }
332  
333 27 $node->mother->remove_daughter($node);
334 27 pop @{$self->{node_stack}};
335 27 return;
336 }
337
338 # it's ok to fall off the end here, not all elements recognized in
339 # start_element need finalizing.
340 }
341  
342 5 1;
↑ Summary Schema/SimpleType.pm »