lib/XML/Schema/Facet/Builtin.pm

filter: Statementstmt 100% 187 / 187 Branchbran 81.2% 26 / 32 Conditioncond 68.6% 35 / 51 MC/DCmcdc 45.4% 15 / 33 Subroutinesub 100% 53 / 53 Podpod n/a totaltotal 88.7% 316 / 356 CC 36 SCAR 8.6
CC
36
Cov
92%
init
4.2
init
4.1
valid
4.0
CRAP 2.4
« lib/XML/Schema/Element.pm ↑ Summary lib/XML/Schema/Type.pm »
1 #============================================================= -*-perl-*-
2 #
3 # XML::Schema::Facet::Builtin
4 #
5 # DESCRIPTION
6 # Definitions of the various facets that are built in to XML Schema.
7 #
8 # AUTHOR
9 # Andy Wardley <abw@kfs.org>
10 #
11 # COPYRIGHT
12 # Copyright (C) 2001 Canon Research Centre Europe Ltd.
13 # All Rights Reserved.
14 #
15 # This module is free software; you can redistribute it and/or
16 # modify it under the same terms as Perl itself.
17 #
18 # REVISION
19 # $Id: Builtin.pm,v 1.1.1.1 2001/08/29 14:30:17 abw Exp $
20 #
21 #========================================================================
22  
23 package XML::Schema::Facet::Builtin;
24  
25 28 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 28 ▶use base qw( XML::Schema::Facet );
Subroutine BEGIN: called CC=1 SCAR=0.0
27 28 ▶use vars qw( $VERSION $DEBUG );
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 28 $VERSION = sprintf("%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
30 28 ▶$DEBUG = 0 unless defined $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $XML::Schema::Facet::Builtin::DEBUG 28 0 28
31  
32  
33 #========================================================================
34 # Fixable
35 # Base class which adds the optional 'fixed' attribute.
36 #========================================================================
37  
38 package XML::Schema::Facet::Fixable;
39 28 ▶use base qw( XML::Schema::Facet );
Subroutine BEGIN: called CC=1 SCAR=0.0
40 28 ▶use vars qw( @OPTIONAL );
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 28 @OPTIONAL = qw( fixed );
43  
44 2 ▶sub fixed {
Subroutine fixed: called CC=2 SCAR=6.9
45 2 my $self = shift;
46 2 ▶ return $self->{ fixed } ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'fixed'} ? : 1 1 2
47 }
48  
49  
50 #========================================================================
51 # length
52 # The length of a string in characters, the length of binary data in
53 # octets, or the length of a list in items.
54 #========================================================================
55  
56 package XML::Schema::Facet::length;
57 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
58 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 6 ▶sub valid {
Subroutine valid: called CC=4 SCAR=13.9
61 6 my ($self, $instance, $type) = @_;
62 6 my $value = $instance->{ value };
63 6 my $length;
64  
65 6 ▶ if (ref $value eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 2 4 6
66 2 $length = scalar @$value;
67 return $length == $self->{ value }
68 2 ▶ || $self->invalid("list has $length elements");
Condition66%2/3
$length == $self->{'value'} || $self->invalid("list has $length elements")
l!l&&r!l&&!r
101
MC/DC50%1/2
$length == $self->{'value'} || $self->invalid("list has $length elements")
$length == $self->{'value'} $self->invalid("list has $length elements")
Truth table66%2/3
A || B
A= $length == $self->{'value'}B= $self->invalid("list has $length elements")
ABresult
1X1
011
000
69 }
70 else {
71 4 $length = length $value;
72 return $length == $self->{ value }
73 4 ▶ || $self->invalid("string has $length characters");
Condition66%2/3
$length == $self->{'value'} || $self->invalid("string has $length characters")
l!l&&r!l&&!r
202
MC/DC50%1/2
$length == $self->{'value'} || $self->invalid("string has $length characters")
$length == $self->{'value'} $self->invalid("string has $length characters")
Truth table66%2/3
A || B
A= $length == $self->{'value'}B= $self->invalid("string has $length characters")
ABresult
1X1
011
000
74 }
75 }
76  
77  
78 #========================================================================
79 # minLength
80 # The minimum length of a string in characters, binary data in
81 # octets, or a list in items.
82 #========================================================================
83  
84 package XML::Schema::Facet::minLength;
85 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
86 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
87  
88 13 ▶sub valid {
Subroutine valid: called CC=4 SCAR=13.9
89 13 my ($self, $instance, $type) = @_;
90 13 my $value = $instance->{ value };
91 13 my $length;
92  
93 13 ▶ if (ref $value eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 6 7 13
94 6 $length = scalar @$value;
95 return $length >= $self->{ value }
96 6 ▶ || $self->invalid("list has $length elements");
Condition66%2/3
$length >= $self->{'value'} || $self->invalid("list has $length elements")
l!l&&r!l&&!r
402
MC/DC50%1/2
$length >= $self->{'value'} || $self->invalid("list has $length elements")
$length >= $self->{'value'} $self->invalid("list has $length elements")
Truth table66%2/3
A || B
A= $length >= $self->{'value'}B= $self->invalid("list has $length elements")
ABresult
1X1
011
000
97 }
98 else {
99 7 $length = length $value;
100 return $length >= $self->{ value }
101 7 ▶ || $self->invalid("string has $length characters");
Condition66%2/3
$length >= $self->{'value'} || $self->invalid("string has $length characters")
l!l&&r!l&&!r
403
MC/DC50%1/2
$length >= $self->{'value'} || $self->invalid("string has $length characters")
$length >= $self->{'value'} $self->invalid("string has $length characters")
Truth table66%2/3
A || B
A= $length >= $self->{'value'}B= $self->invalid("string has $length characters")
ABresult
1X1
011
000
102 }
103 }
104  
105  
106 #========================================================================
107 # maxLength
108 # The maximum length of a string in characters, binary data in
109 # octets, or a list in items.
110 #========================================================================
111  
112 package XML::Schema::Facet::maxLength;
113 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
114 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116 33 ▶sub valid {
Subroutine valid: called CC=4 SCAR=13.9
117 33 my ($self, $instance, $type) = @_;
118 33 my $value = $instance->{ value };
119 33 my $length;
120  
121 33 ▶ if (ref $value eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 12 21 33
122 12 $length = scalar @$value;
123 return $length <= $self->{ value }
124 12 ▶ || $self->invalid("list has $length elements");
Condition66%2/3
$length <= $self->{'value'} || $self->invalid("list has $length elements")
l!l&&r!l&&!r
903
MC/DC50%1/2
$length <= $self->{'value'} || $self->invalid("list has $length elements")
$length <= $self->{'value'} $self->invalid("list has $length elements")
Truth table66%2/3
A || B
A= $length <= $self->{'value'}B= $self->invalid("list has $length elements")
ABresult
1X1
011
000
125 }
126 else {
127 21 $length = length $value;
128 return $length <= $self->{ value }
129 21 ▶ || $self->invalid("string has $length characters");
Condition66%2/3
$length <= $self->{'value'} || $self->invalid("string has $length characters")
l!l&&r!l&&!r
1704
MC/DC50%1/2
$length <= $self->{'value'} || $self->invalid("string has $length characters")
$length <= $self->{'value'} $self->invalid("string has $length characters")
Truth table66%2/3
A || B
A= $length <= $self->{'value'}B= $self->invalid("string has $length characters")
ABresult
1X1
011
000
130 }
131 }
132  
133  
134 #========================================================================
135 # pattern
136 # Regular expression pattern.
137 #========================================================================
138  
139 package XML::Schema::Facet::pattern;
140 28 ▶use base qw( XML::Schema::Facet );
Subroutine BEGIN: called CC=1 SCAR=0.0
141  
142 28 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
143 28 my ($self, $instance, $type) = @_;
144  
145 28 ▶ return ($instance->{ value } =~ /$self->{ value }/)
Condition66%2/3
$instance->{'value'} =~ /$self->{'value'}/ || $self->invalid('string mismatch')
l!l&&r!l&&!r
16012
MC/DC50%1/2
$instance->{'value'} =~ /$self->{'value'}/ || $self->invalid('string mismatch')
$instance->{'value'} =~ /$self->{'value'}/ $self->invalid('string mismatch')
Truth table66%2/3
A || B
A= $instance->{'value'} =~ /$self->{'value'}/B= $self->invalid('string mismatch')
ABresult
1X1
011
000
146 || $self->invalid("string mismatch");
147 }
148  
149  
150 #========================================================================
151 # enumeration
152 # Note: need to do numerical/string equality match based on underlying
153 # type.
154 #========================================================================
155  
156 package XML::Schema::Facet::enumeration;
157 28 ▶use base qw( XML::Schema::Facet );
Subroutine BEGIN: called CC=1 SCAR=0.0
158  
159 5 ▶sub init {
Subroutine init: called CC=3 SCAR=11.0
160 5 my ($self, $config) = @_;
161
162 5 ▶ $self->SUPER::init($config)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($config) or return 5 0 5
163 || return;
164  
165 # ensure value is folded to a list reference
166 5 my $value = $self->{ value };
167 5 ▶ $self->{ value } = [ $value ]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "ARRAY" 1 4 5
168 unless ref $value eq 'ARRAY';
169  
170 5 return $self
171 }
172  
173 12 ▶sub valid {
Subroutine valid: called CC=4 SCAR=13.9
174 12 my ($self, $instance, $type) = @_;
175 12 my $value = $instance->{ value };
176 12 my $allow = $self->{ value };
177  
178 12 foreach my $v (@$allow) {
179 17 ▶ return 1 if $value eq $v;
Branch: 1 branch
BranchTrueFalseTotal
if $value eq $v 9 8 17
180 }
181 3 local $" = "', '";
182 return $self->error(
183 3 ▶ $self->{ errmsg } || "string mismatch ('$value' not in: '@$allow')"
Condition100%2/2
$self->{'errmsg'} || "string mismatch ('${value}' not in: '@${allow}')"
l!l
12
MC/DC100%1/1
$self->{'errmsg'} || "string mismatch ('${value}' not in: '@${allow}')"
$self->{'errmsg'}
Truth table100%2/2
A
A= $self->{'errmsg'}
Aresult
11
00
184 );
185 }
186  
187  
188 #========================================================================
189 # whiteSpace
190 # Rule for whitespace normalisation. Value should be one of:
191 # preserve: leave intact
192 # replace: replace newlines, carriage returns and tabs with spaces
193 # collapse: as per replace, collapsing multiple whitespace into a
194 # single and stripping leading/trailing whitespaces
195 #========================================================================
196  
197 package XML::Schema::Facet::whiteSpace;
198 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
199 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
200  
201 123 ▶sub init {
Subroutine init: called CC=3 SCAR=11.1
202 123 my ($self, $config) = @_;
203  
204 123 ▶ $self->SUPER::init($config)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($config) or return 123 0 123
205 || return;
206  
207 123 ▶ return $self->{ value } =~ /^preserve|replace|collapse$/
Branch: 1 branch
BranchTrueFalseTotal
$self->{'value'} =~ /^preserve|replace|collapse$/ ? : 122 1 123
208 ? $self
209 : $self->error('value must be one of: preserve, replace, collapse')
210 }
211  
212 353 ▶sub valid {
Subroutine valid: called CC=4 SCAR=13.9
213 353 my ($self, $instance, $type) = @_;
214 353 my $action = $self->{ value };
215 353 ▶ return 1 if $action eq 'preserve';
Branch: 1 branch
BranchTrueFalseTotal
if $action eq "preserve" 1 352 353
216  
217 352 for ($instance->{ value }) {
218 352 s/[\r\n\t]/ /g;
219 352 ▶ if ($action eq 'collapse') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "collapse") 350 2 352
220 350 s/ +/ /g;
221 350 s/^ +//;
222 350 s/ +$//;
223 }
224 }
225 352 return 1;
226 }
227  
228  
229 #========================================================================
230 # maxInclusive
231 # Constrain a value to be within an inclusive upper bound.
232 #========================================================================
233  
234 package XML::Schema::Facet::maxInclusive;
235 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
236 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
237  
238 66 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
239 66 my ($self, $instance, $type) = @_;
240 return $instance->{ value } <= $self->{ value }
241 66 ▶ || $self->invalid("value is $instance->{ value }");
Condition66%2/3
$instance->{'value'} <= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
l!l&&r!l&&!r
54012
MC/DC50%1/2
$instance->{'value'} <= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
$instance->{'value'} <= $self->{'value'} $self->invalid("value is $instance->{'value'}")
Truth table66%2/3
A || B
A= $instance->{'value'} <= $self->{'value'}B= $self->invalid("value is $instance->{'value'}")
ABresult
1X1
011
000
242 }
243  
244  
245 #========================================================================
246 # maxExclusive
247 # Constrain a value to be within an exclusive upper bound.
248 #========================================================================
249  
250 package XML::Schema::Facet::maxExclusive;
251 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
252 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
253  
254 10 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
255 10 my ($self, $instance, $type) = @_;
256 return $instance->{ value } < $self->{ value }
257 10 ▶ || $self->invalid("value is $instance->{ value }");
Condition66%2/3
$instance->{'value'} < $self->{'value'} || $self->invalid("value is $instance->{'value'}")
l!l&&r!l&&!r
802
MC/DC50%1/2
$instance->{'value'} < $self->{'value'} || $self->invalid("value is $instance->{'value'}")
$instance->{'value'} < $self->{'value'} $self->invalid("value is $instance->{'value'}")
Truth table66%2/3
A || B
A= $instance->{'value'} < $self->{'value'}B= $self->invalid("value is $instance->{'value'}")
ABresult
1X1
011
000
258 }
259  
260  
261 #========================================================================
262 # minInclusive
263 # Constrain a value to be within an inclusive upper bound.
264 #========================================================================
265  
266 package XML::Schema::Facet::minInclusive;
267 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
268 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
269  
270 74 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
271 74 my ($self, $instance, $type) = @_;
272 return $instance->{ value } >= $self->{ value }
273 74 ▶ || $self->invalid("value is $instance->{ value }");
Condition66%2/3
$instance->{'value'} >= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
l!l&&r!l&&!r
62012
MC/DC50%1/2
$instance->{'value'} >= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
$instance->{'value'} >= $self->{'value'} $self->invalid("value is $instance->{'value'}")
Truth table66%2/3
A || B
A= $instance->{'value'} >= $self->{'value'}B= $self->invalid("value is $instance->{'value'}")
ABresult
1X1
011
000
274 }
275  
276  
277 #========================================================================
278 # minExclusive
279 # Constrain a value to be within an exclusive upper bound.
280 #========================================================================
281  
282 package XML::Schema::Facet::minExclusive;
283 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
284 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
285  
286 2 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
287 2 my ($self, $instance, $type) = @_;
288 return $instance->{ value } > $self->{ value }
289 2 ▶ || $self->invalid("value is $instance->{ value }");
Condition66%2/3
$instance->{'value'} > $self->{'value'} || $self->invalid("value is $instance->{'value'}")
l!l&&r!l&&!r
101
MC/DC50%1/2
$instance->{'value'} > $self->{'value'} || $self->invalid("value is $instance->{'value'}")
$instance->{'value'} > $self->{'value'} $self->invalid("value is $instance->{'value'}")
Truth table66%2/3
A || B
A= $instance->{'value'} > $self->{'value'}B= $self->invalid("value is $instance->{'value'}")
ABresult
1X1
011
000
290 }
291  
292  
293 #========================================================================
294 # precision
295 #========================================================================
296  
297 package XML::Schema::Facet::precision;
298 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
299 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
300  
301 4 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
302 4 my ($self, $instance, $type) = @_;
303 return $instance->{ precision } <= $self->{ value }
304 4 ▶ || $self->invalid("value is $instance->{ value }");
Condition66%2/3
$instance->{'precision'} <= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
l!l&&r!l&&!r
202
MC/DC50%1/2
$instance->{'precision'} <= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
$instance->{'precision'} <= $self->{'value'} $self->invalid("value is $instance->{'value'}")
Truth table66%2/3
A || B
A= $instance->{'precision'} <= $self->{'value'}B= $self->invalid("value is $instance->{'value'}")
ABresult
1X1
011
000
305 }
306  
307  
308 #========================================================================
309 # scale
310 #========================================================================
311  
312 package XML::Schema::Facet::scale;
313 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
314 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
315  
316 118 ▶sub valid {
Subroutine valid: called CC=2 SCAR=7.1
317 118 my ($self, $instance, $type) = @_;
318 return $instance->{ scale } <= $self->{ value }
319 118 ▶ || $self->invalid("value is $instance->{ value }");
Condition66%2/3
$instance->{'scale'} <= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
l!l&&r!l&&!r
11305
MC/DC50%1/2
$instance->{'scale'} <= $self->{'value'} || $self->invalid("value is $instance->{'value'}")
$instance->{'scale'} <= $self->{'value'} $self->invalid("value is $instance->{'value'}")
Truth table66%2/3
A || B
A= $instance->{'scale'} <= $self->{'value'}B= $self->invalid("value is $instance->{'value'}")
ABresult
1X1
011
000
320 }
321  
322  
323 #========================================================================
324 # encoding
325 #========================================================================
326  
327 package XML::Schema::Facet::encoding;
328 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
329 28 ▶use vars qw( $ERROR );
Subroutine BEGIN: called CC=1 SCAR=0.0
330  
331 2 ▶sub init {
Subroutine init: called CC=3 SCAR=11.1
332 2 my ($self, $config) = @_;
333  
334 2 ▶ $self->SUPER::init($config)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($config) or return 2 0 2
335 || return;
336  
337 2 ▶ return $self->{ value } =~ /^hex|base64$/
Branch: 1 branch
BranchTrueFalseTotal
$self->{'value'} =~ /^hex|base64$/ ? : 1 1 2
338 ? $self
339 : $self->error("encoding value must be 'hex' or 'base64'")
340 }
341  
342  
343 #========================================================================
344 # duration
345 #========================================================================
346  
347 package XML::Schema::Facet::duration;
348 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
349 28 ▶use vars qw( $ERROR $TYPE );
Subroutine BEGIN: called CC=1 SCAR=0.0
350  
351 19 ▶sub init {
Subroutine init: called CC=4 SCAR=14.5
352 19 my ($self, $config) = @_;
353 19 ▶ $self->SUPER::init($config)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($config) or return 19 0 19
354 || return;
355 19 ▶ $TYPE ||= XML::Schema::Type::timeDuration->new();
Condition66%2/3
$XML::Schema::Facet::duration::TYPE ||= "XML::Schema::Type::timeDuration"->new
l!l&&r!l&&!r
1270
MC/DC0%0/2
$XML::Schema::Facet::duration::TYPE ||= "XML::Schema::Type::timeDuration"->new
$XML::Schema::Facet::duration::TYPE "XML::Schema::Type::timeDuration"->new
Truth table66%2/3
A ||= B
A= $XML::Schema::Facet::duration::TYPEB= "XML::Schema::Type::timeDuration"->new
ABresult
1X1
011
000
356 $self->{ value } = $TYPE->instance($self->{ value })
357 19 ▶ || return $self->error('duration ' . $TYPE->error());
Condition50%1/2
$XML::Schema::Facet::duration::TYPE->instance($self->{'value'}) || (return $self->error('duration ' . $XML::Schema::Facet::duration::TYPE->error))
l!l
190
MC/DC0%0/1
$XML::Schema::Facet::duration::TYPE->instance($self->{'value'}) || (return $self->error('duration ' . $XML::Schema::Facet::duration::TYPE->error))
$XML::Schema::Facet::duration::TYPE->instance($self->{'value'})
Truth table50%1/2
A
A= $XML::Schema::Facet::duration::TYPE->instance($self->{'value'})
Aresult
11
00
358 19 return $self;
359 }
360  
361 # custom install method which installs duration in the facet hash but not
362 # the runtime list because it doesn't have validation rules.
363  
364 19 ▶sub install {
Subroutine install: called CC=1 SCAR=0.0
365 19 my ($self, $facets, $table) = @_;
366 # $self->DEBUG("partially installing $self into type as $self->{ name }\n");
367 19 $table->{ $self->{ name } } = $self;
368 19 return 1;
369 }
370  
371  
372 #========================================================================
373 # period
374 #========================================================================
375  
376 package XML::Schema::Facet::period;
377 28 ▶use base qw( XML::Schema::Facet::Fixable );
Subroutine BEGIN: called CC=1 SCAR=0.0
378 28 ▶use vars qw( $ERROR $TYPE );
Subroutine BEGIN: called CC=1 SCAR=0.0
379  
380 19 ▶sub init {
Subroutine init: called CC=4 SCAR=14.0
381 19 my ($self, $config) = @_;
382 19 ▶ $self->SUPER::init($config)
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($config) or return 19 0 19
383 || return;
384 19 ▶ $TYPE ||= XML::Schema::Type::timeDuration->new();
Condition66%2/3
$XML::Schema::Facet::period::TYPE ||= "XML::Schema::Type::timeDuration"->new
l!l&&r!l&&!r
1270
MC/DC0%0/2
$XML::Schema::Facet::period::TYPE ||= "XML::Schema::Type::timeDuration"->new
$XML::Schema::Facet::period::TYPE "XML::Schema::Type::timeDuration"->new
Truth table66%2/3
A ||= B
A= $XML::Schema::Facet::period::TYPEB= "XML::Schema::Type::timeDuration"->new
ABresult
1X1
011
000
385 $self->{ value } = $TYPE->instance($self->{ value })
386 19 ▶ || return $self->error('period ' . $TYPE->error());
Condition100%2/2
$XML::Schema::Facet::period::TYPE->instance($self->{'value'}) || (return $self->error('period ' . $XML::Schema::Facet::period::TYPE->error))
l!l
181
MC/DC100%1/1
$XML::Schema::Facet::period::TYPE->instance($self->{'value'}) || (return $self->error('period ' . $XML::Schema::Facet::period::TYPE->error))
$XML::Schema::Facet::period::TYPE->instance($self->{'value'})
Truth table100%2/2
A
A= $XML::Schema::Facet::period::TYPE->instance($self->{'value'})
Aresult
11
00
387 18 return $self;
388 }
389  
390 # as per duration
391  
392 18 ▶sub install {
Subroutine install: called CC=1 SCAR=0.0
393 18 my ($self, $facets, $table) = @_;
394 # $self->DEBUG("partially installing $self into type as $self->{ name }\n");
395 18 $table->{ $self->{ name } } = $self;
396 18 return 1;
397 }
398  
399  
400  
401 28 1;
402 __END__
« lib/XML/Schema/Element.pm ↑ Summary lib/XML/Schema/Type.pm »