Compile/Schema/Specs.pm

filter: Statementstmt 97.9% 48 / 49 Branchbran 66.6% 12 / 18 Conditioncond 66.6% 8 / 12 MC/DCmcdc 50.0% 4 / 8 Subroutinesub 87.5% 7 / 8 Podpod 100% 3 / 3 totaltotal 83.6% 82 / 98 CC 14 SCAR 22.8
CC
14
Cov
86%
builtInType
14.9
predefinedSchema
2.1
predefinedSchemas
2.0
CRAP 9.8
« Compile/Schema/BuiltInFacets.pm ↑ Summary Compile/Translate/Reader.pm »
1 # Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution XML-Compile. Meta-POD processed with
6 # OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package XML::Compile::Schema::Specs;{
10 50 our $VERSION = '1.64';
11 }
12  
13  
14 50 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 50 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 50 ▶use Log::Report 'xml-compile';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 50 ▶use XML::Compile::Schema::BuiltInTypes qw/%builtin_types/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 50 ▶use XML::Compile::Util qw/SCHEMA1999 SCHEMA2000 SCHEMA2001 unpack_type/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22  
23 ### Who will extend this?
24 # everything which is not caught by a special will need to pass through
25 # the official meta-scheme: the scheme of the scheme. These lists are
26 # used to restrict the namespace to the specified, hiding all helper
27 # types.
28  
29 50 my @builtin_common = qw/
30 boolean
31 byte
32 date
33 decimal
34 double
35 duration
36 ENTITIES
37 ENTITY
38 float
39 ID
40 IDREF
41 IDREFS
42 int
43 integer
44 language
45 long
46 Name
47 NCName
48 negativeInteger
49 NMTOKEN
50 NMTOKENS
51 nonNegativeInteger
52 nonPositiveInteger
53 NOTATION
54 pattern
55 positiveInteger
56 QName
57 short
58 string
59 time
60 token
61 unsignedByte
62 unsignedInt
63 unsignedLong
64 unsignedShort
65 yearMonthDuration
66 /;
67  
68 50 my @builtin_extra_1999 = qw/
69 binary
70 recurringDate
71 recurringDay
72 recurringDuration
73 timeDuration
74 timeInstant
75 timePeriod
76 uriReference
77 year
78 /;
79  
80 50 my @builtin_extra_2000 = (@builtin_extra_1999, qw/
81 anyType
82 CDATA
83 / );
84  
85 50 my @builtin_extra_2001 = qw/
86 anySimpleType
87 anyType
88 anyURI
89 base64Binary
90 dateTime
91 dayTimeDuration
92 error
93 gDay
94 gMonth
95 gMonthDay
96 gYear
97 gYearMonth
98 hexBinary
99 normalizedString
100 precisionDecimal
101 /;
102  
103 50 my %builtin_public_1999 = map { ($_ => $_) }
104 @builtin_common, @builtin_extra_1999;
105  
106 50 my %builtin_public_2000 = map { ($_ => $_) }
107 @builtin_common, @builtin_extra_2000;
108  
109 50 my %builtin_public_2001 = map { ($_ => $_) }
110 @builtin_common, @builtin_extra_2001;
111  
112 50 my %sloppy_int_version =
113 ( integer => 'int'
114 , long => 'int'
115 , nonNegativeInteger => 'unsigned_int'
116 , nonPositiveInteger => 'non_pos_int'
117 , positiveInteger => 'positive_int'
118 , negativeInteger => 'negative_int'
119 , unsignedLong => 'unsigned_int'
120 , unsignedInt => 'unsigned_int'
121 );
122  
123 50 my %sloppy_float_version = map +($_ => 'sloppy_float'),
124 qw/decimal precisionDecimal float double/;
125  
126 50 my %schema_1999 =
127 ( uri_xsd => SCHEMA1999
128 , uri_xsi => SCHEMA1999.'-instance'
129  
130 , builtin_public => \%builtin_public_1999
131 );
132  
133 50 my %schema_2000 =
134 ( uri_xsd => SCHEMA2000
135 , uri_xsi => SCHEMA2000.'-instance'
136  
137 , builtin_public => \%builtin_public_2000
138 );
139  
140 50 my %schema_2001 =
141 ( uri_xsd => SCHEMA2001
142 , uri_xsi => SCHEMA2001 .'-instance'
143  
144 , builtin_public => \%builtin_public_2001
145 );
146  
147 50 my %schemas = map { ($_->{uri_xsd} => $_) }
148 \%schema_1999, \%schema_2000, \%schema_2001;
149  
150  
151 0 ▶sub predefinedSchemas() { keys %schemas }
Subroutine predefinedSchemas: not called CC=1 SCAR=6.9
Pod documented
152  
153  
154 58 ▶sub predefinedSchema($) { defined $_[1] ? $schemas{$_[1]} : () }
Subroutine predefinedSchema: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 58 0 58
155  
156  
157 sub builtInType($$;$@)
158 2772 ▶{ my ($class, $node, $ns) = (shift, shift, shift);
Subroutine builtInType: called CC=13 SCAR=27.0
Pod documented
159 2772 ▶ my $name = @_ % 1 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 1 ? : 0 2772 2772
160 2772 ▶ ($ns, $name) = unpack_type $ns
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 2772 0 2772
161 unless defined $name;
162  
163 2772 ▶ my $schema = $schemas{$ns}
Branch: 1 branch
BranchTrueFalseTotal
my $schema = $schemas{$ns} or return () 1613 1159 2772
164 or return ();
165  
166 1613 my %args = @_;
167  
168 return $builtin_types{boolean_with_Types_Serialiser}
169 1613 ▶ if $args{json_friendly} && $name eq 'boolean';
Branch: 1 branch
BranchTrueFalseTotal
if $args{"json_friendly"} and $name eq "boolean" 0 1613 1613
Condition33%1/3
$args{"json_friendly"} and $name eq "boolean"
!ll&&!rl&&r
161300
MC/DC0%0/2
$args{"json_friendly"} and $name eq "boolean"
$args{"json_friendly"} $name eq "boolean"
Truth table33%1/3
A and B
A= $args{"json_friendly"}B= $name eq "boolean"
ABresult
0X0
100
111
170  
171 return $builtin_types{$sloppy_int_version{$name}}
172 1613 ▶ if $args{sloppy_integers} && exists $sloppy_int_version{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"sloppy_integers"} and exists $sloppy_int_version{$name} 32 1581 1613
Condition100%3/3
$args{"sloppy_integers"} and exists $sloppy_int_version{$name}
!ll&&!rl&&r
144813332
MC/DC100%2/2
$args{"sloppy_integers"} and exists $sloppy_int_version{$name}
$args{"sloppy_integers"} exists $sloppy_int_version{$name}
Truth table100%3/3
A and B
A= $args{"sloppy_integers"}B= exists $sloppy_int_version{$name}
ABresult
0X0
100
111
173  
174 1581 ▶ if($args{sloppy_floats} && (my $maptype = $sloppy_float_version{$name}))
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"sloppy_floats"} and my $maptype = $sloppy_float_version{$name}) 28 1553 1581
Condition100%3/3
$args{"sloppy_floats"} and my $maptype = $sloppy_float_version{$name}
!ll&&!rl&&r
1548528
MC/DC100%2/2
$args{"sloppy_floats"} and my $maptype = $sloppy_float_version{$name}
$args{"sloppy_floats"} my $maptype = $sloppy_float_version{$name}
Truth table100%3/3
A and B
A= $args{"sloppy_floats"}B= my $maptype = $sloppy_float_version{$name}
ABresult
0X0
100
111
175 { return $builtin_types{sloppy_float_force_NV}
176 28 ▶ if $args{json_friendly} && $maptype eq 'sloppy_float';
Branch: 1 branch
BranchTrueFalseTotal
if $args{"json_friendly"} and $maptype eq "sloppy_float" 0 28 28
Condition33%1/3
$args{"json_friendly"} and $maptype eq "sloppy_float"
!ll&&!rl&&r
2800
MC/DC0%0/2
$args{"json_friendly"} and $maptype eq "sloppy_float"
$args{"json_friendly"} $maptype eq "sloppy_float"
Truth table33%1/3
A and B
A= $args{"json_friendly"}B= $maptype eq "sloppy_float"
ABresult
0X0
100
111
177  
178 28 return $builtin_types{$maptype};
179 }
180  
181 # only official names are exported this way
182 1553 my $public = $schema->{builtin_public}{$name};
183 1553 ▶ defined $public ? $builtin_types{$public} : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $public ? : 1553 0 1553
184 }
185  
186 50 1;
« Compile/Schema/BuiltInFacets.pm ↑ Summary Compile/Translate/Reader.pm »