| 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::Translate::Writer;{ | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 47 | our $VERSION = '1.64'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 47 | ▶ | use base 'XML::Compile::Translate'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 47 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 47 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 47 | ▶ | no warnings 'once', 'recursion'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 47 | ▶ | use Log::Report 'xml-compile'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 47 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 47 | ▶ | use Scalar::Util qw/blessed weaken/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 47 | ▶ | use Encode qw/encode/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 47 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 47 | ▶ | use XML::Compile::Util qw/pack_type unpack_type type_of_node SCHEMA2001i | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 47 | SCHEMA2001 odd_elements even_elements/; | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | # Each action implementation returns a code reference, which will be | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # used to do the run-time work. The principle of closures is used to | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # keep the important information. Be sure that you understand closures | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # before you attempt to change anything. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # The returned writer subroutines will always be called | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # $writer->($doc, $value) | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 1187 | ▶ | sub actsAs($) { $_[1] eq 'WRITER' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
actsAs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | sub makeTagQualified | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 132 | ▶ | { # my ($self, $path, $node, $local, $ns) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeTagQualified: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | # my $prefix = $self->_registerNSprefix('', $ns, 1); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # length($prefix) ? "$prefix:$local" : $local; | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 132 | my $prefix = $_[0]->_registerNSprefix('', $_[4], 1); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 132 | ▶ | length($prefix) ? "$prefix:$_[3]" : $_[3]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | sub makeTagUnqualified | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 841 | ▶ | { # my ($self, $path, $node, $local, $ns) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeTagUnqualified: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | # $local; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 841 | $_[3]; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub _typemapClass($$) | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | ▶ | { my ($self, $type, $class) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_typemapClass: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 47 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | keys %{$class.'::'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | or error __x"class {pkg} for typemap {type} is not loaded" | ||||||||||||||||||||||||||||||||||||||||||
| 60 | , pkg => $class, type => $type; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | $class->can('toXML') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | or error __x"class {pkg} does not implement toXML(), required for typemap {type}" | ||||||||||||||||||||||||||||||||||||||||||
| 64 | , pkg => $class, type => $type; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my ($doc, $values, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | UNIVERSAL::isa($values, $class) ? $values->toXML($type, $doc) : $values; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub _typemapObject($$) | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | { my ($self, $type, $object) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_typemapObject: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | $object->can('toXML') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | or error __x"object of class {pkg} does not implement toXML(), required for typemap {type}" | ||||||||||||||||||||||||||||||||||||||||||
| 77 | , pkg => ref($object), type => $type; | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my ($doc, $values, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | blessed($values) ? $object->toXML($values, $type, $doc) : $values; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | sub typemapToHooks($$) | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 360 | ▶ | { my ($self, $hooks, $typemap) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
typemapToHooks: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 360 | ▶ | while(my($type, $action) = each %$typemap) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | { defined $action or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | my $hook; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 3 | ▶ | if(!ref $action) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | { $hook = $self->_typemapClass($type, $action); | |||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | trace "created writer hook for type $type to class $action"; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif(ref $action eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | { $hook = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | my ($doc, $values, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | blessed($values) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | ? $action->(WRITER => $values, $type, $doc) | ||||||||||||||||||||||||||||||||||||||||||
| 99 | : $values; | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | trace "created writer hook for type $type to CODE"; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | else | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | { $hook = $self->_typemapObject($type, $action); | |||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | trace "created reader hook for type $type to object"; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | push @$hooks, +{action => 'WRITER', type => $type, before => $hook}; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 360 | $hooks; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub makeElementWrapper | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 360 | ▶ | { my ($self, $path, $processor) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeElementWrapper: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 362 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 362 | my ($doc, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 362 | ▶ | UNIVERSAL::isa($doc, 'XML::LibXML::Document') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | or error __x"first argument of call to writer must be an XML::LibXML::Document"; | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 362 | my $top = $processor->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 319 | $doc->indexElements; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 319 | $top; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 360 | }; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 47 | *makeAttributeWrapper = \&makeElementWrapper; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | sub makeWrapperNs | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 55 | ▶ | { my ($self, $path, $processor, $index, $filter) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeWrapperNs: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 55 | my @entries; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 55 | ▶ | $filter = sub {$_[2]} if ref $filter ne 'CODE'; # only the used | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 55 | foreach my $entry (sort {$a->{prefix} cmp $b->{prefix}} values %$index) | |||||||||||||||||||||||||||||||||||||||||
| 135 | { # ANY components are frustrating this | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 184 | ▶ | $filter->($entry->{uri}, $entry->{prefix}, $entry->{used}) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 73 | push @entries, [ $entry->{uri}, $entry->{prefix} ]; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 73 | $entry->{used} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 55 | ▶ | @entries or return $processor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 55 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 55 | ▶ | my $node = $processor->(@_) or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 52 | ▶ | UNIVERSAL::isa($node, 'XML::LibXML::Element') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | or return $node; | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 52 | $node->setNamespace(@$_, 0) for @entries; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 52 | $node; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 54 | }; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | sub makeSequence($@) | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 214 | ▶ | { my ($self, $path, @pairs) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeSequence: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 214 | ▶ | if(@pairs==2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 83 | { my ($take, $do) = @pairs; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | return | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | ref $do eq 'ANY' ? bless(sub { $do->(@_) }, 'BLOCK') | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | : ref $do eq 'BLOCK' ? $do | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 72 | ▶ | : bless sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 72 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 72 | ▶ | defined $values or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 72 | $do->($doc, delete $values->{$take}); | |||||||||||||||||||||||||||||||||||||||||
| 165 | 83 | ▶ | }, 'BLOCK'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 138 | ▶ | bless sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 138 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 138 | ▶ | defined $values or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 138 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 138 | my @do = @pairs; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 138 | ▶ | while(@do) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 314 | { my ($take, $do) = (shift @do, shift @do); | |||||||||||||||||||||||||||||||||||||||||
| 176 | push @res | ||||||||||||||||||||||||||||||||||||||||||
| 177 | , ref $do eq 'BLOCK' ? $do->($doc, $values) | ||||||||||||||||||||||||||||||||||||||||||
| 178 | : ref $do eq 'ANY' ? $do->($doc, $values) | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 314 | ▶ | : $do->($doc, delete $values->{$take}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 131 | @res; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 131 | }, 'BLOCK'; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | sub makeChoice($@) | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 38 | ▶ | { my ($self, $path) = (shift, shift); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeChoice: called CC=6 SCAR=20.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 38 | my (%do, @specials); | |||||||||||||||||||||||||||||||||||||||||
| 188 | 38 | ▶ | while(@_) # protect order of specials | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 89 | { my ($el, $do) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 89 | ▶ | if(ref $do eq 'BLOCK' || ref $do eq 'ANY') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $do eq "BLOCK" or ref $do eq "ANY"
MC/DC50%1/2
ref $do eq "BLOCK" or ref $do eq "ANY"
ref $do eq "BLOCK"
ref $do eq "ANY"
Truth table66%2/3
A or B
A= ref $do eq "BLOCK"B= ref $do eq "ANY"
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 12 | { push @specials, $do } | |||||||||||||||||||||||||||||||||||||||||
| 192 | 77 | else { $do{$el} = $do } | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 38 | ▶ | if(!@specials && keys %do==1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not @specials and keys %do == 1
MC/DC100%2/2
not @specials and keys %do == 1
not @specials
keys %do == 1
Truth table100%3/3
not(A) and B
A= not @specialsB= keys %do == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | { my ($take, $do) = %do; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | return bless sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 199 | defined $values && defined $values->{$take} | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | ? $do->($doc, delete $values->{$take}) : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $values and defined $values->{$take}
MC/DC0%0/2
defined $values and defined $values->{$take}
defined $values
defined $values->{$take}
Truth table33%1/3
A and B
A= defined $valuesB= defined $values->{$take}
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | }, 'BLOCK'; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 43 | ▶ | bless sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=36.4
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 43 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 43 | ▶ | defined $values or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 43 | foreach my $take (keys %do) | |||||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | #warn "TAKE($take) = ", (defined $values->{$take} ? 'defined' : "undef"); | ||||||||||||||||||||||||||||||||||||||||||
| 210 | return $do{$take}->($doc, delete $values->{$take}) | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 74 | ▶ | if defined $values->{$take}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | #warn "TRY SPECIALS"; | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 9 | my $starter = keys %$values; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 9 | foreach (@specials) | |||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | ▶ | { my @d = try { $_->($doc, $values) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | ▶ | if(my $f = $@->wasFatal(class => 'misfit')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | { # misfit error is ok, if nothing consumed | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | trace "misfit $path ".$@->wasFatal->message; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | $err->reportAll if $starter != keys %$values; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | elsif(defined $@) {$@->reportAll} | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 6 | return @d; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | #warn "BLURK!"; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | # blurk... any element with minOccurs=0 or default? | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | foreach (values %do) | |||||||||||||||||||||||||||||||||||||||||
| 233 | 5 | ▶ | { my @d = try { $_->($doc, undef) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 5 | ▶ | return @d if !$@ && @d; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $@ and @d
MC/DC50%1/2
not $@ and @d
not $@
@d
Truth table66%2/3
not(A) and B
A= not $@B= @d
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | foreach (@specials) | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | { my @d = try { $_->($doc, undef) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if($@->wasFatal(class => 'misfit')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | { $@->reportAll if $starter != keys %$values; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | elsif(defined $@) {$@->reportAll} | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return @d; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | (); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 36 | }, 'BLOCK'; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | sub makeAll($@) | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 14 | ▶ | { my ($self, $path, @pairs) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAll: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 14 | ▶ | if(@pairs==2 && !ref $pairs[1]) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@pairs == 2 and not ref $pairs[1]
MC/DC0%0/2
@pairs == 2 and not ref $pairs[1]
@pairs == 2
not ref $pairs[1]
Truth table66%2/3
A and not(B)
A= @pairs == 2B= not ref $pairs[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | { my ($take, $do) = @pairs; | |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | return bless sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $do->($doc, delete $values->{$take}); | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | }, 'BLOCK'; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 13 | ▶ | return bless sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 13 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 13 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 13 | my @do = @pairs; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 13 | ▶ | while(@do) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 35 | { my ($take, $do) = (shift @do, shift @do); | |||||||||||||||||||||||||||||||||||||||||
| 268 | push @res | ||||||||||||||||||||||||||||||||||||||||||
| 269 | , ref $do eq 'BLOCK' || ref $do eq 'ANY' | ||||||||||||||||||||||||||||||||||||||||||
| 270 | ? $do->($doc, $values) | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 35 | ▶ | : $do->($doc, delete $values->{$take}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $do eq "BLOCK" or ref $do eq "ANY"
MC/DC50%1/2
ref $do eq "BLOCK" or ref $do eq "ANY"
ref $do eq "BLOCK"
ref $do eq "ANY"
Truth table66%2/3
A or B
A= ref $do eq "BLOCK"B= ref $do eq "ANY"
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 13 | @res; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 14 | }, 'BLOCK'; | |||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # | ||||||||||||||||||||||||||||||||||||||||||
| 278 | ## Element | ||||||||||||||||||||||||||||||||||||||||||
| 279 | # | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | # see comment BlockHandler: undef means zero but success | ||||||||||||||||||||||||||||||||||||||||||
| 282 | sub makeElementHandler | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 462 | ▶ | { my ($self, $path, $label, $min,$max, $required, $optional) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeElementHandler: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 462 | ▶ | $max eq "0" and return sub {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 461 | ▶ | if($min==0 && $max eq 'unbounded') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 0 and $max eq "unbounded"
MC/DC100%2/2
$min == 0 and $max eq "unbounded"
$min == 0
$max eq "unbounded"
Truth table100%3/3
A and B
A= $min == 0B= $max eq "unbounded"
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | { return | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 12 | ▶ | sub { my ($doc, $values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 12 | ▶ | my @values = ref $values eq 'ARRAY' ? @$values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | : defined $values ? $values : (); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 12 | ▶ | @values ? map {$optional->($doc,$_)} @values : (undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 450 | ▶ | if($max eq 'unbounded') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | { return | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | ▶ | sub { my ($doc, $values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | ▶ | my @values = ref $values eq 'ARRAY' ? @$values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | : defined $values ? $values : (); | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | my @d = ( (map { $required->($doc, shift @values) } 1..$min) | |||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | , (map { $optional->($doc, $_) } @values) ); | |||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | @d ? @d : (undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 94 | ▶ | return sub { my @d = $optional->(@_); @d ? @d : undef } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 449 | ▶ | if $min==0 && $max==1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 0 and $max == 1
MC/DC100%2/2
$min == 0 and $max == 1
$min == 0
$max == 1
Truth table100%3/3
A and B
A= $min == 0B= $max == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 361 | ▶ | return $required | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 1 and $max == 1
MC/DC100%2/2
$min == 1 and $max == 1
$min == 1
$max == 1
Truth table100%3/3
A and B
A= $min == 1B= $max == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | if $min==1 && $max==1; | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 12 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 12 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 314 | my @values | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 12 | ▶ | = ref $values eq 'ARRAY' ? @$values : defined $values ? $values : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 12 | ▶ | @values <= $max | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | or error "too many elements for `{tag}', max {max} found {nr} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 319 | , tag => $label, max => $max, nr => (scalar @values) | ||||||||||||||||||||||||||||||||||||||||||
| 320 | , path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 12 | my @d = map { $required->($doc, shift @values) } 1..$min; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 12 | ▶ | push @d, $optional->($doc, shift @values) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@values and @d < $max
MC/DC50%1/2
@values and @d < $max
@values
@d < $max
Truth table66%2/3
A and B
A= @valuesB= @d < $max
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | while @values && @d < $max; | ||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 12 | ▶ | @d ? @d : (undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | # To reflect the difference between a block which did not "succeed hence | ||||||||||||||||||||||||||||||||||||||||||
| 331 | # produced nothing", and "did succeed by producing nothing" (minOccurs=0) | ||||||||||||||||||||||||||||||||||||||||||
| 332 | # the later is represented by an undef value. | ||||||||||||||||||||||||||||||||||||||||||
| 333 | sub makeBlockHandler | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 275 | ▶ | { my ($self, $path, $label, $min, $max, $process, $kind, $multi) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeBlockHandler: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 275 | ▶ | if($min==0 && $max eq 'unbounded') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 0 and $max eq "unbounded"
MC/DC100%2/2
$min == 0 and $max eq "unbounded"
$min == 0
$max eq "unbounded"
Truth table100%3/3
A and B
A= $min == 0B= $max eq "unbounded"
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 14 | ▶ | { my $code = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 14 | my $doc = shift; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 14 | ▶ | my $values = $_[0] ? delete shift->{$multi} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 14 | ▶ | ref $values eq 'ARRAY' ? (map {$process->($doc, {%$_})} @$values) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | : defined $values ? $process->($doc, $values) | ||||||||||||||||||||||||||||||||||||||||||
| 342 | : (undef); | ||||||||||||||||||||||||||||||||||||||||||
| 343 | 14 | }; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 14 | return ($multi, bless($code, 'BLOCK')); | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 261 | ▶ | if($max eq 'unbounded') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 5 | ▶ | { my $code = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 5 | my $doc = shift; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 5 | ▶ | my $values = $_[0] ? delete shift->{$multi} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 5 | ▶ | my @values = ref $values eq 'ARRAY' ? @$values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | : defined $values ? $values : (); | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 5 | ▶ | @values >= $min | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | or error __x"too few blocks for `{tag}' specified, got {found} need {min} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 356 | , tag => $multi, found => scalar @values | ||||||||||||||||||||||||||||||||||||||||||
| 357 | , min => $min, path => $path, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 5 | map {$process->($doc, {%$_}) } @values; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 6 | return ($multi, bless($code, 'BLOCK')); | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 255 | ▶ | if($min==0 && $max==1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 0 and $max == 1
MC/DC100%2/2
$min == 0 and $max == 1
$min == 0
$max == 1
Truth table100%3/3
A and B
A= $min == 0B= $max == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 5 | ▶ | { my $code = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 5 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 367 | 5 | ▶ | my @values = ref $values eq 'ARRAY' ? @$values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | : defined $values ? $values : (); | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 5 | ▶ | @values <= 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | or error __x"only one block value for `{tag}', not {count} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 371 | , tag => $multi, count => scalar @values | ||||||||||||||||||||||||||||||||||||||||||
| 372 | , path => $path, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | # @values ? $process->($doc, $values[0]) : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 5 | ▶ | @values or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 5 | my $starter = keys %$values; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 5 | ▶ | my @d = try { $process->($doc, $values[0]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 5 | ▶ | $@->wasFatal(class => 'misfit') && $starter==keys %$values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$@->wasFatal("class", "misfit") and $starter == keys %$values
MC/DC100%2/2
$@->wasFatal("class", "misfit") and $starter == keys %$values
$@->wasFatal("class", "misfit")
$starter == keys %$values
Truth table100%3/3
A and B
A= $@->wasFatal("class", "misfit")B= $starter == keys %$values
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | or $@->reportAll; | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 4 | @d; | |||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | }; | |||||||||||||||||||||||||||||||||||||||||
| 383 | 5 | return ($label, bless($code, 'BLOCK')); | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | 250 | ▶ | if($min==1 && $max==1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 1 and $max == 1
MC/DC100%2/2
$min == 1 and $max == 1
$min == 1
$max == 1
Truth table100%3/3
A and B
A= $min == 1B= $max == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 233 | ▶ | { my $code = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 233 | my @d = $process->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 224 | ▶ | @d or error __x"no match for required block `{tag}' at {path}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | , tag => $multi, path => $path, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 223 | @d; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 239 | }; | |||||||||||||||||||||||||||||||||||||||||
| 393 | 239 | return ($label, bless($code, 'BLOCK')); | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 11 | my $opt = $max - $min; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 10 | ▶ | my $code = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 10 | my $doc = shift; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 10 | my $values = delete shift->{$multi}; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 10 | ▶ | my @values = ref $values eq 'ARRAY' ? @$values | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | : defined $values ? $values : (); | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 10 | ▶ | @values >= $min && @values <= $max | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@values >= $min and @values <= $max
MC/DC100%2/2
@values >= $min and @values <= $max
@values >= $min
@values <= $max
Truth table100%3/3
A and B
A= @values >= $minB= @values <= $max
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | or error __x"found {found} blocks for `{tag}', must be between {min} and {max} inclusive at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 405 | , tag => $multi, min => $min, max => $max, path => $path | ||||||||||||||||||||||||||||||||||||||||||
| 406 | , found => scalar @values, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 7 | map { $process->($doc, {%$_}) } @values; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 11 | ($multi, bless($code, 'BLOCK')); | |||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | sub makeRequired | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 354 | ▶ | { my ($self, $path, $label, $do) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeRequired: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 311 | ▶ | my $req = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 311 | my @nodes = $do->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 418 | 307 | ▶ | return @nodes if @nodes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 8 | ▶ | error __x"required data for block (starts with `{tag}') missing at {path}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | , tag => $label, path => $path, _class => 'misfit' | ||||||||||||||||||||||||||||||||||||||||||
| 422 | if ref $do eq 'BLOCK'; | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 8 | error __x"required value for element `{tag}' missing at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 425 | , tag => $label, path => $path, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 354 | }; | |||||||||||||||||||||||||||||||||||||||||
| 427 | 354 | ▶ | bless $req, 'BLOCK' if ref $do eq 'BLOCK'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 354 | $req; | |||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | sub makeElement | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 807 | ▶ | { my ($self, $path, $ns, $childname, $do) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeElement: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 807 | ▶ | sub { defined $_[1] ? $do->(@_) : () }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | sub makeElementFixed | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 4 | ▶ | { my ($self, $path, $ns, $childname, $do, $fixed) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeElementFixed: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 4 | ▶ | $fixed = $fixed->value if ref $fixed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 4 | my ($doc, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 4 | ▶ | my $ret = defined $value ? $do->($doc, $value) : return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | return $ret | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ret and $ret->textContent eq $fixed
MC/DC50%1/2
defined $ret and $ret->textContent eq $fixed
defined $ret
$ret->textContent eq $fixed
Truth table66%2/3
A and B
A= defined $retB= $ret->textContent eq $fixed
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | if defined $ret && $ret->textContent eq $fixed; | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | ▶ | defined $ret | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | or error __x"required element `{name}' with fixed value `{fixed}' missing at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 448 | , name => $childname, fixed => $fixed, path => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 449 | , _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | error __x"element `{name}' has value fixed to `{fixed}', got `{value}' at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 452 | , name => $childname, fixed => $fixed | ||||||||||||||||||||||||||||||||||||||||||
| 453 | , value => $ret->textContent, path => $path, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 454 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | sub makeElementDefault | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 18 | ▶ | { my ($self, $path, $ns, $childname, $do, $default) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeElementDefault: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 18 | my $mode = $self->{default_values}; | |||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | $mode eq 'IGNORE' | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 18 | ▶ | and return sub { defined $_[1] ? $do->(@_) : () }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | $mode eq 'EXTEND' | ||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | ▶ | and return sub { $do->($_[0], (defined $_[1] ? $_[1] : $default)) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | $mode eq 'MINIMAL' | ||||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | ▶ | and return sub { defined $_[1] && $_[1] ne $default ? $do->(@_) : () }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.3
Branch: 2 branches
Condition66%2/3
defined $_[1] and $_[1] ne $default
MC/DC50%1/2
defined $_[1] and $_[1] ne $default
defined $_[1]
$_[1] ne $default
Truth table66%2/3
A and B
A= defined $_[1]B= $_[1] ne $default
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | error __x"illegal default_values mode `{mode}'", mode => $mode; | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | sub makeElementAbstract | ||||||||||||||||||||||||||||||||||||||||||
| 474 | 8 | ▶ | { my ($self, $path, $ns, $childname, $do, $default) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeElementAbstract: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 1 | ▶ | sub { defined $_[1] or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | error __x"attempt to instantiate abstract element `{name}' at {where}" | |||||||||||||||||||||||||||||||||||||||||
| 477 | , name => $childname, where => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | # | ||||||||||||||||||||||||||||||||||||||||||
| 482 | # complexType/ComplexContent | ||||||||||||||||||||||||||||||||||||||||||
| 483 | # | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | sub nil($) | ||||||||||||||||||||||||||||||||||||||||||
| 486 | 20 | ▶ | { my ($self, $path) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nil: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 20 | $self->makeTagQualified($path, undef, 'nil', SCHEMA2001i); | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | sub makeComplexElement | ||||||||||||||||||||||||||||||||||||||||||
| 491 | 242 | ▶ | { my ($self, $path, $tag, $elems, $attrs, $any_attr,undef, $is_nillable) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeComplexElement: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 242 | my @elems = odd_elements @$elems; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 242 | my @attrs = @$attrs; | |||||||||||||||||||||||||||||||||||||||||
| 494 | 242 | my $tags = join ', ', grep defined | |||||||||||||||||||||||||||||||||||||||||
| 495 | , even_elements(@$elems), even_elements(@attrs); | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 242 | my @anya = @$any_attr; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 242 | my $iut = $self->{ignore_unused_tags}; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 242 | ▶ | my $nilattr = $is_nillable ? $self->nil($path) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | return | ||||||||||||||||||||||||||||||||||||||||||
| 501 | sub | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 244 | ▶ | { my ($doc, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=20 SCAR=35.1
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 244 | ▶ | $data = { _ => 'NIL' } if $data eq 'NIL'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 244 | ▶ | return $doc->importNode($data) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | if UNIVERSAL::isa($data, 'XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | 244 | ▶ | unless(UNIVERSAL::isa($data, 'HASH')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | { defined $data | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | or error __x"complex `{tag}' requires data at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 511 | , tag => $tag, path => $path, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | error __x"complex `{tag}' requires a HASH of input data, not `{got}' at {path}" | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $data || $data
MC/DC0%0/2
ref $data || $data
ref $data
$data
Truth table0%0/3
A || B
A= ref $dataB= $data
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | , tag => $tag, got => (ref $data || $data), path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 244 | my $copy = { %$data }; # do not destroy callers hash | |||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 244 | ▶ | my @childs = ($is_nillable && (delete $copy->{_} || '') eq 'NIL') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
$is_nillable and (delete $copy->{"_"} || "") eq "NIL"
delete $copy->{'_'} || ''
MC/DC100%2/2
$is_nillable and (delete $copy->{"_"} || "") eq "NIL"
$is_nillable
delete $copy->{'_'}
Truth table100%3/3
A and B
A= $is_nillableB= delete $copy->{'_'}
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | ? $doc->createAttribute($nilattr => 'true') | ||||||||||||||||||||||||||||||||||||||||||
| 521 | : map($_->($doc, $copy), @elems); | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 231 | ▶ | for(my $i=0; $i<@attrs; $i+=2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 92 | { push @childs, $attrs[$i+1]->($doc, delete $copy->{$attrs[$i]}); | |||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | push @childs, $_->($doc, $copy) | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 229 | for @anya; | |||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | 229 | ▶ | if(%$copy) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | { my @not_used | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | ▶ | = defined $iut ? (grep $_ !~ $iut, keys %$copy) : keys %$copy; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | ▶ | if(@not_used) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 3 | { trace "available tags are: $tags"; | |||||||||||||||||||||||||||||||||||||||||
| 536 | 3 | mistake __xn "tag `{tags}' not used at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 537 | , "unused tags {tags} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 538 | , scalar @not_used, tags => [sort @not_used], path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 229 | my $node = $doc->createElement($tag); | |||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | 229 | foreach my $child (@childs) | |||||||||||||||||||||||||||||||||||||||||
| 545 | 525 | ▶ | { defined $child or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 477 | ▶ | if(ref $child) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | 477 | ▶ | { next if UNIVERSAL::isa($child, 'XML::LibXML::Text') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
UNIVERSAL::isa($child, "XML::LibXML::Text") and $child->data eq ""
MC/DC0%0/2
UNIVERSAL::isa($child, "XML::LibXML::Text") and $child->data eq ""
UNIVERSAL::isa($child, "XML::LibXML::Text")
$child->data eq ""
Truth table33%1/3
A and B
A= UNIVERSAL::isa($child, "XML::LibXML::Text")B= $child->data eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 548 | && $child->data eq ''; | ||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | else | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | { length $child or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | $child = XML::LibXML::Text->new($child); | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 477 | $node->addChild($child); | |||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 229 | $node; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 242 | }; | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | # | ||||||||||||||||||||||||||||||||||||||||||
| 562 | # complexType/simpleContent | ||||||||||||||||||||||||||||||||||||||||||
| 563 | # | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | sub makeTaggedElement | ||||||||||||||||||||||||||||||||||||||||||
| 566 | 9 | ▶ | { my ($self, $path, $tag, $st, $attrs, $attrs_any,undef, $is_nillable) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeTaggedElement: called CC=2 SCAR=7.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | 9 | my @attrs = @$attrs; | |||||||||||||||||||||||||||||||||||||||||
| 568 | 9 | my @anya = @$attrs_any; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 9 | ▶ | my $nilattr = $is_nillable ? $self->nil($path) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 9 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=16 SCAR=31.3
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 9 | my ($doc, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 573 | 9 | ▶ | return $doc->importNode($data) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | if UNIVERSAL::isa($data, 'XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 9 | ▶ | my $copy = UNIVERSAL::isa($data,'HASH') ? {%$data} : {_ => $data}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 9 | my $content = delete $copy->{_}; | |||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | 9 | my ($node, @childs); | |||||||||||||||||||||||||||||||||||||||||
| 580 | 9 | ▶ | if(UNIVERSAL::isa($content, 'XML::LibXML::Node')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | { $node = $doc->importNode($content); | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | ▶ | elsif($is_nillable && $content eq 'NIL') | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$is_nillable and $content eq "NIL"
MC/DC50%1/2
$is_nillable and $content eq "NIL"
$is_nillable
$content eq "NIL"
Truth table66%2/3
A and B
A= $is_nillableB= $content eq "NIL"
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | { push @childs, $doc->createAttribute($nilattr => 'true'); | |||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | elsif(defined $content) | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 8 | { push @childs, $st->($doc, $content); | |||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | 9 | ▶ | for(my $i=0; $i<@attrs; $i+=2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | 10 | { push @childs, $attrs[$i+1]->($doc, delete $copy->{$attrs[$i]}); | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | push @childs, $_->($doc, $copy) | ||||||||||||||||||||||||||||||||||||||||||
| 595 | 9 | for @anya; | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 9 | ▶ | if(my @not_used = sort keys %$copy) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | { error __xn "tag `{tags}' not processed at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 599 | , "unprocessed tags {tags} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 600 | , scalar @not_used, tags => \@not_used, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 9 | ▶ | $node or @childs or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$node or @childs
MC/DC0%0/2
$node or @childs
$node
@childs
Truth table33%1/3
A or B
A= $nodeB= @childs
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 9 | ▶ | $node ||= $doc->createElement($tag); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$node ||= $doc->createElement($tag)
MC/DC0%0/2
$node ||= $doc->createElement($tag)
$node
$doc->createElement($tag)
Truth table33%1/3
A ||= B
A= $nodeB= $doc->createElement($tag)
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | $node->addChild | ||||||||||||||||||||||||||||||||||||||||||
| 606 | ( UNIVERSAL::isa($_, 'XML::LibXML::Node') ? $_ | ||||||||||||||||||||||||||||||||||||||||||
| 607 | : $doc->createTextNode(defined $_ ? $_ : '')) | ||||||||||||||||||||||||||||||||||||||||||
| 608 | 9 | ▶ | for @childs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 609 | 9 | $node; | |||||||||||||||||||||||||||||||||||||||||
| 610 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | # | ||||||||||||||||||||||||||||||||||||||||||
| 614 | # complexType mixed or complexContent mixed | ||||||||||||||||||||||||||||||||||||||||||
| 615 | # | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | sub makeMixedElement | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 1 | ▶ | { my ($self, $path, $tag, $elems, $attrs, $attrs_any,undef, $is_nillable) =@_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeMixedElement: called CC=6 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | my @attrs = @$attrs; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | my @anya = @$attrs_any; | |||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | ▶ | my $nilattr = $is_nillable ? $self->nil($path) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | (my $locname = $tag) =~ s/.*\://; | |||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | my $mixed = $self->{mixed_elements}; | |||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | ▶ | if($mixed eq 'ATTRIBUTES') { ; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | elsif($mixed eq 'STRUCTURAL') | ||||||||||||||||||||||||||||||||||||||||||
| 627 | { # mixed_element eq STRUCTURAL is handled earlier | ||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | panic "mixed structural handled as normal element"; | |||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | else { error __x"unknown mixed_elements value `{value}'", value => $mixed } | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | ▶ | if(!@attrs && !@anya) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@attrs or @anya
MC/DC0%0/2
@attrs or @anya
@attrs
@anya
Truth table33%1/3
A or B
A= @attrsB= @anya
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | { return | ||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | sub { my ($doc, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | my $node = ref $data eq 'HASH' ? $data->{_} : $data; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | return $doc->importNode($node) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 637 | if UNIVERSAL::isa($node, 'XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | error __x"mixed `{tag}' requires XML::LibXML::Node, not `{found}' at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 639 | , tag => $tag, found => $data, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | my $iut = $self->{ignore_unused_tags}; | |||||||||||||||||||||||||||||||||||||||||
| 644 | 2 | ▶ | sub { my ($doc, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=21 SCAR=46.1
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 2 | ▶ | defined $data or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 2 | ▶ | return $doc->importNode($data) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | if UNIVERSAL::isa($data, 'XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | 1 | ▶ | my $copy = UNIVERSAL::isa($data, 'HASH') ? {%$data} : {_ => $data}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 1 | my $content = delete $copy->{_}; | |||||||||||||||||||||||||||||||||||||||||
| 652 | 1 | ▶ | defined $content or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | #XXX there are no regression test for these options | ||||||||||||||||||||||||||||||||||||||||||
| 655 | 1 | my $node; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 1 | ▶ | if(blessed $content && $content->isa('XML::LibXML::Node')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
builtin::blessed($content) and $content->isa("XML::LibXML::Node")
MC/DC0%0/2
builtin::blessed($content) and $content->isa("XML::LibXML::Node")
builtin::blessed($content)
$content->isa("XML::LibXML::Node")
Truth table33%1/3
A and B
A= builtin::blessed($content)B= $content->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | 1 | { $node = $doc->importNode($content); | |||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||
| 659 | ▶ | elsif($is_nillable && $content eq 'NIL') | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$is_nillable and $content eq "NIL"
MC/DC0%0/2
$is_nillable and $content eq "NIL"
$is_nillable
$content eq "NIL"
Truth table0%0/3
A and B
A= $is_nillableB= $content eq "NIL"
| |||||||||||||||||||||||||||||||||||||||||||
| 660 | { # nillable element | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | $node = $doc->createElement($tag); | |||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $node->setAttribute($nilattr => 'true'); | |||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||
| 664 | elsif($content =~ /\<.*?\>|\&\w+\;/) | ||||||||||||||||||||||||||||||||||||||||||
| 665 | { # XXX I do not know a way to fill text nodes without getting | ||||||||||||||||||||||||||||||||||||||||||
| 666 | # entity encoding on them. Apparently, libxml2 has a | ||||||||||||||||||||||||||||||||||||||||||
| 667 | # xmlStringTextNoenc, which is not provided in XML::LibXML. | ||||||||||||||||||||||||||||||||||||||||||
| 668 | # Now, we need the expensive roundtrip, via the parser. | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | my $frag = XML::LibXML->new | |||||||||||||||||||||||||||||||||||||||||
| 671 | ->parse_balanced_chunk(encode utf8 => $content); | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | $node = $frag->firstChild; | |||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if($node->localName ne $locname) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | { # <nodes> --> <$locname>$nodes</$locname> | ||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | my $c = $node; | |||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $node = $doc->createElement($tag); | |||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $node->appendChild($frag); | |||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||
| 681 | else | ||||||||||||||||||||||||||||||||||||||||||
| 682 | { # Plain text | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $node = $doc->createElement($tag); | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $node->appendText($content); | |||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 1 | my @childs; | |||||||||||||||||||||||||||||||||||||||||
| 688 | 1 | ▶ | for(my $i=0; $i<@attrs; $i+=2) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | 1 | { push @childs, $attrs[$i+1]->($doc, delete $copy->{$attrs[$i]}); | |||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | push @childs, $_->($doc, $copy) | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 1 | for @anya; | |||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | 1 | ▶ | if(%$copy) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 696 | { my @not_used | ||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | ▶ | = defined $iut ? (grep $_ !~ $iut, keys %$copy) : keys %$copy; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | if(my @not_used = sort keys %$copy) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | { error __xn "tag `{tags}' not processed at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 701 | , "unprocessed tags {tags} at {path}", scalar @not_used | ||||||||||||||||||||||||||||||||||||||||||
| 702 | , tags => [sort @not_used], path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | ▶ | @childs or return $node; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 707 | $node->addChild | ||||||||||||||||||||||||||||||||||||||||||
| 708 | ( ref $_ && $_->isa('XML::LibXML::Node') ? $_ | ||||||||||||||||||||||||||||||||||||||||||
| 709 | : $doc->createTextNode(defined $_ ? $_ : '')) | ||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | ▶ | for @childs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
ref $_ and $_->isa("XML::LibXML::Node")
MC/DC0%0/2
ref $_ and $_->isa("XML::LibXML::Node")
ref $_
$_->isa("XML::LibXML::Node")
Truth table33%1/3
A and B
A= ref $_B= $_->isa("XML::LibXML::Node")
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | $node; | |||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | # | ||||||||||||||||||||||||||||||||||||||||||
| 716 | # simpleType | ||||||||||||||||||||||||||||||||||||||||||
| 717 | # | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | sub makeSimpleElement | ||||||||||||||||||||||||||||||||||||||||||
| 720 | 585 | ▶ | { my ($self, $path, $tag, $st, undef, undef, undef, $is_nillable) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeSimpleElement: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 721 | 585 | ▶ | my $nilattr = $is_nillable ? $self->nil($path) : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | 509 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||
| 724 | 509 | my ($doc, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 725 | 509 | ▶ | return $doc->importNode($data) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | if UNIVERSAL::isa($data, 'XML::LibXML::Element'); | ||||||||||||||||||||||||||||||||||||||||||
| 727 | $data = $data->{_} | ||||||||||||||||||||||||||||||||||||||||||
| 728 | 509 | ▶ | if ref $data eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | 509 | ▶ | my $value = ($is_nillable && $data eq 'NIL') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$is_nillable and $data eq "NIL"
MC/DC100%2/2
$is_nillable and $data eq "NIL"
$is_nillable
$data eq "NIL"
Truth table100%3/3
A and B
A= $is_nillableB= $data eq "NIL"
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | ? $doc->createAttribute($nilattr => 'true') | ||||||||||||||||||||||||||||||||||||||||||
| 732 | : $st->($doc, $data); | ||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 478 | ▶ | defined $value | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | or return (); | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 478 | my $node = $doc->createElement($tag); | |||||||||||||||||||||||||||||||||||||||||
| 738 | 478 | ▶ | error __x"expected single value for {tag}, but got {type}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value eq "ARRAY" or ref $value eq "HASH"
MC/DC0%0/2
ref $value eq "ARRAY" or ref $value eq "HASH"
ref $value eq "ARRAY"
ref $value eq "HASH"
Truth table33%1/3
A or B
A= ref $value eq "ARRAY"B= ref $value eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 739 | , tag => $tag, type => ref($value) | ||||||||||||||||||||||||||||||||||||||||||
| 740 | if ref $value eq 'ARRAY' || ref $value eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | 478 | ▶ | $node->addChild | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 743 | ( UNIVERSAL::isa($value, 'XML::LibXML::Node') ? $value | ||||||||||||||||||||||||||||||||||||||||||
| 744 | : $doc->createTextNode(defined $value ? $value : '')); | ||||||||||||||||||||||||||||||||||||||||||
| 745 | 478 | $node; | |||||||||||||||||||||||||||||||||||||||||
| 746 | 585 | }; | |||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | sub makeBuiltin | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 716 | ▶ | { my ($self, $path, $node, $type, $def, $check_values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeBuiltin: called CC=6 SCAR=18.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 716 | ▶ | my $check = $check_values ? $def->{check} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 716 | ▶ | my $err = $path eq $type | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | ? N__"illegal value `{value}' for type {type}" | ||||||||||||||||||||||||||||||||||||||||||
| 754 | : N__"illegal value `{value}' for type {type} at {path}"; | ||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | 716 | my $format = $def->{format}; | |||||||||||||||||||||||||||||||||||||||||
| 757 | 716 | my $trans = $self->{prefixes}; | |||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | $check | ||||||||||||||||||||||||||||||||||||||||||
| 760 | ? ( defined $format | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 537 | ▶ | ? sub { defined $_[1] or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 762 | 515 | my $value = $format->($_[1], $trans, $path); | |||||||||||||||||||||||||||||||||||||||||
| 763 | 514 | ▶ | return $value if defined $value && $check->($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and &$check($value)
MC/DC50%1/2
defined $value and &$check($value)
defined $value
&$check($value)
Truth table66%2/3
A and B
A= defined $valueB= &$check($value)
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | 11 | error __x$err, value => $value, type => $type, path => $path; | |||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | 28 | ▶ | : sub { return $_[1] if !defined $_[1] || $check->($_[1]); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=15.4
Branch: 1 branch
Condition33%1/3
not defined $_[1] or &$check($_[1])
MC/DC0%0/2
not defined $_[1] or &$check($_[1])
not defined $_[1]
&$check($_[1])
Truth table33%1/3
not(A) or B
A= not defined $_[1]B= &$check($_[1])
| |||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | error __x$err, value => $_[1], type => $type, path => $path; | |||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||
| 769 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 770 | : ( defined $format | ||||||||||||||||||||||||||||||||||||||||||
| 771 | 6 | ▶ | ? sub { defined $_[1] ? $format->($_[1], $trans, $path) : undef } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 772 | 47 | ▶ | : sub { $_[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 773 | 716 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | # simpleType | ||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | sub makeList | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 28 | ▶ | { my ($self, $path, $st) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeList: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | 34 | ▶ | sub { my ($doc, $v) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 781 | 34 | ▶ | defined $v or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 782 | 34 | ▶ | join ' ', grep defined, map {$st->($doc, $_)} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | ref $v eq 'ARRAY' ? @$v : $v; | ||||||||||||||||||||||||||||||||||||||||||
| 784 | 28 | }; | |||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | sub makeFacetsList | ||||||||||||||||||||||||||||||||||||||||||
| 788 | 12 | ▶ | { my ($self, $path, $st, $info, $early, $late) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeFacetsList: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | 12 | my @e = grep defined, @$early; | |||||||||||||||||||||||||||||||||||||||||
| 790 | 12 | my @l = grep defined, @$late; | |||||||||||||||||||||||||||||||||||||||||
| 791 | 12 | ▶ | sub { my ($doc, $v) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 12 | ▶ | defined $v or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | 12 | $_->($v) for @l; | |||||||||||||||||||||||||||||||||||||||||
| 794 | 8 | ▶ | my $list = join ' ', map $st->($doc, $_), ref $v eq 'ARRAY' ? @$v : $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 795 | 8 | ▶ | defined $list && length $list or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $list and length $list
MC/DC0%0/2
defined $list and length $list
defined $list
length $list
Truth table33%1/3
A and B
A= defined $listB= length $list
| |||||||||||||||||||||||||||||||||||||||||||
| 796 | 8 | do { $list = $_->($list) } for @e; | |||||||||||||||||||||||||||||||||||||||||
| 797 | 7 | $list; | |||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 799 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | sub makeFacets | ||||||||||||||||||||||||||||||||||||||||||
| 802 | 87 | ▶ | { my ($self, $path, $st, $info, $early, $late) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeFacets: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 87 | ▶ | @$early || @$late or return $st; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$early or @$late
MC/DC100%2/2
@$early or @$late
@$early
@$late
Truth table100%3/3
A or B
A= @$earlyB= @$late
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | 74 | ▶ | sub { my ($doc, $v) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | 74 | ▶ | defined $v or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | 74 | $v = $_->($v) for @$late; | |||||||||||||||||||||||||||||||||||||||||
| 807 | 54 | $v = $st->($doc, $v); | |||||||||||||||||||||||||||||||||||||||||
| 808 | 53 | ▶ | defined $v or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 809 | 53 | $v = $_->($v) for @$early; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 52 | $v; | |||||||||||||||||||||||||||||||||||||||||
| 811 | 86 | }; | |||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | sub makeUnion | ||||||||||||||||||||||||||||||||||||||||||
| 815 | 18 | ▶ | { my ($self, $path, @types) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeUnion: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 816 | 25 | ▶ | sub { my ($doc, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | 25 | ▶ | defined $value or return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 818 | 25 | ▶ | for(@types) {my $v = try { $_->($doc, $value) }; $@ or return $v } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | 2 | ▶ | substr $value, 20, -5, '...' if length($value) > 50; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 821 | 2 | error __x"no match for `{text}' in union at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 822 | , text => $value, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 823 | 18 | }; | |||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | sub makeSubstgroup | ||||||||||||||||||||||||||||||||||||||||||
| 827 | 9 | ▶ | { my ($self, $path, $type, %done) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeSubstgroup: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | keys %done or return bless sub { () }, 'BLOCK'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | 9 | my %do = map { @$_ } values %done; | |||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | bless | ||||||||||||||||||||||||||||||||||||||||||
| 833 | 12 | ▶ | sub { my ($doc, $values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 834 | #warn "SUBST($type) AVAILABLE ARE ", join ', ', keys %do; | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 12 | foreach my $take (keys %do) | |||||||||||||||||||||||||||||||||||||||||
| 836 | 22 | { my $subst = delete $values->{$take}; | |||||||||||||||||||||||||||||||||||||||||
| 837 | 22 | ▶ | defined $subst or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||
| 839 | 12 | return $do{$take}->($doc, $subst); | |||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | (); | |||||||||||||||||||||||||||||||||||||||||
| 842 | 9 | }, 'BLOCK'; | |||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | # Attributes | ||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||
| 847 | sub makeAttributeRequired | ||||||||||||||||||||||||||||||||||||||||||
| 848 | 11 | ▶ | { my ($self, $path, $ns, $tag, $label, $do) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAttributeRequired: called CC=1 SCAR=0.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 10 | ▶ | sub { my $value = $do->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | 10 | ▶ | return $_[0]->createAttribute($tag, $value) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | if defined $value; | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | error __x"attribute `{tag}' is required at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 855 | , tag => $tag, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 856 | 11 | }; | |||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | sub makeAttributeProhibited | ||||||||||||||||||||||||||||||||||||||||||
| 860 | 3 | ▶ | { my ($self, $path, $ns, $tag, $label, $do) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAttributeProhibited: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | 3 | ▶ | sub { my $value = $do->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 863 | 3 | ▶ | defined $value or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 1 | error __x"attribute `{tag}' is prohibited at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 866 | , tag => $tag, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 867 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | sub makeAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 871 | 83 | ▶ | { my ($self, $path, $ns, $tag, $label, $do) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAttribute: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 872 | 82 | ▶ | sub { my $value = $do->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 873 | 81 | ▶ | defined $value ? $_[0]->createAttribute($tag, $value) : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 874 | 83 | }; | |||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||
| 877 | sub makeAttributeDefault | ||||||||||||||||||||||||||||||||||||||||||
| 878 | 7 | ▶ | { my ($self, $path, $ns, $tag, $label, $do, $default_node) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAttributeDefault: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||
| 880 | 7 | my $mode = $self->{default_values}; | |||||||||||||||||||||||||||||||||||||||||
| 881 | $mode eq 'IGNORE' | ||||||||||||||||||||||||||||||||||||||||||
| 882 | and return sub | ||||||||||||||||||||||||||||||||||||||||||
| 883 | 3 | ▶ | { my $value = $do->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | 3 | ▶ | defined $value ? $_[0]->createAttribute($tag, $value) : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | 7 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | 4 | my $default = $default_node->value; | |||||||||||||||||||||||||||||||||||||||||
| 888 | $mode eq 'EXTEND' | ||||||||||||||||||||||||||||||||||||||||||
| 889 | and return sub | ||||||||||||||||||||||||||||||||||||||||||
| 890 | 2 | ▶ | { my $value = $do->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | 2 | ▶ | defined $value or $value = $default; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 2 | $_[0]->createAttribute($tag, $value); | |||||||||||||||||||||||||||||||||||||||||
| 893 | 4 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | $mode eq 'MINIMAL' | ||||||||||||||||||||||||||||||||||||||||||
| 896 | and return sub | ||||||||||||||||||||||||||||||||||||||||||
| 897 | 2 | ▶ | { my $value = $do->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 898 | 2 | ▶ | return () if defined $value && $value eq $default; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $value and $value eq $default
MC/DC50%1/2
defined $value and $value eq $default
defined $value
$value eq $default
Truth table66%2/3
A and B
A= defined $valueB= $value eq $default
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 1 | $_[0]->createAttribute($tag, $value); | |||||||||||||||||||||||||||||||||||||||||
| 900 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | error __x"illegal default_values mode `{mode}'", mode => $mode; | |||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | sub makeAttributeFixed | ||||||||||||||||||||||||||||||||||||||||||
| 906 | 6 | ▶ | { my ($self, $path, $ns, $tag, $label, $do, $fixed) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAttributeFixed: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 907 | 6 | ▶ | $fixed = $fixed->value if ref $fixed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | 5 | ▶ | sub { my ($doc, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 910 | 5 | ▶ | defined $value or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | 4 | ▶ | $value eq $fixed | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | or error __x"value of attribute `{tag}' is fixed to `{fixed}', not `{got}' at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 914 | , tag => $tag, got => $value, fixed => $fixed, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 3 | $doc->createAttribute($tag, $fixed); | |||||||||||||||||||||||||||||||||||||||||
| 917 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||
| 920 | # any | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | sub _split_any_list($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 923 | 14 | ▶ | { my ($path, $type, $v) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_any_list: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||
| 924 | 14 | ▶ | my @nodes = ref $v eq 'ARRAY' ? @$v : defined $v ? $v : return ([], []); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 925 | 14 | my (@attrs, @elems); | |||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | 14 | foreach my $node (@nodes) | |||||||||||||||||||||||||||||||||||||||||
| 928 | 14 | ▶ | { UNIVERSAL::isa($node, 'XML::LibXML::Node') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | or error __x"elements for 'any' are XML::LibXML nodes, not {string} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 930 | , string => $node, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | 14 | ▶ | if($node->isa('XML::LibXML::Attr')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 933 | 12 | { push @attrs, $node; | |||||||||||||||||||||||||||||||||||||||||
| 934 | 12 | next; | |||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | 2 | ▶ | if($node->isa('XML::LibXML::Element')) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 938 | 2 | { push @elems, $node; | |||||||||||||||||||||||||||||||||||||||||
| 939 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 940 | } | ||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | error __x"an XML::LibXML::Element or ::Attr is expected as 'any' or 'anyAttribute value with {type}, but a {kind} was found at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 943 | , type => $type, kind => ref $node, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | 14 | return (\@attrs, \@elems); | |||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||
| 949 | sub makeAnyAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 950 | 5 | ▶ | { my ($self, $path, $handler, $yes, $no, $process) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAnyAttribute: called CC=3 SCAR=11.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 951 | 5 | ▶ | my %yes = map +($_ => 1), @{$yes || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$yes || []
MC/DC100%1/1
$yes || []
$yes
Truth table100%2/2
A
A= $yes
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | 5 | ▶ | my %no = map +($_ => 1), @{$no || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$no || []
MC/DC100%1/1
$no || []
$no
Truth table100%2/2
A
A= $no
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | 5 | my $prefs = $self->{prefixes}; | |||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | 5 | weaken $self; | |||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | bless | ||||||||||||||||||||||||||||||||||||||||||
| 958 | 5 | ▶ | sub { my ($doc, $values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=30.8
| |||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 5 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 961 | 5 | foreach my $label (sort keys %$values) | |||||||||||||||||||||||||||||||||||||||||
| 962 | 10 | { my ($type, $ns, $local); | |||||||||||||||||||||||||||||||||||||||||
| 963 | 10 | ▶ | if(substr($label, 0, 1) eq '{') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | 10 | { ($ns, $local) = unpack_type $label; | |||||||||||||||||||||||||||||||||||||||||
| 965 | 10 | $type = $label; | |||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | elsif(index($label, ':') >= 0) | ||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | { (my $prefix, $local) = split ':', $label, 2; | |||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | my $match = first {$_->{prefix} eq $prefix} values %$prefs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | my $ns = $match ? $match->{uri} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $type = pack_type $ns, $local; | |||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | else {next} # not fully qualified, not an 'any' | |||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | 10 | ▶ | $yes{$ns} or next if keys %yes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
keys %yes && ($yes{$ns} || (next))
$yes{$ns} or next
MC/DC0%0/2
keys %yes && ($yes{$ns} || (next))
keys %yes
$yes{$ns}
Truth table66%2/3
A && B
A= keys %yesB= $yes{$ns}
| |||||||||||||||||||||||||||||||||||||||||||
| 976 | 8 | ▶ | $no{$ns} and next if keys %no; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
keys %no && ($no{$ns} && (next))
$no{$ns} and next
MC/DC0%0/2
keys %no && ($no{$ns} && (next))
keys %no
$no{$ns}
Truth table66%2/3
A && B
A= keys %noB= $no{$ns}
| |||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | 6 | ▶ | my $value = delete $values->{$label} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | 6 | my ($attrs, $elems) = _split_any_list $path, $type, $value; | |||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | 6 | ▶ | $values->{$type} = $elems if @$elems; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | 6 | ▶ | @$attrs or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | 6 | foreach my $node (@$attrs) | |||||||||||||||||||||||||||||||||||||||||
| 985 | 6 | { my $nodetype = type_of_node $node; | |||||||||||||||||||||||||||||||||||||||||
| 986 | 6 | ▶ | next if $nodetype eq $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | error __x"provided 'anyAttribute' node has type {type}, but labeled with {other} at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 989 | , type => $nodetype, other => $type, path => $path | ||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | 6 | push @res, @$attrs; | |||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||
| 994 | 5 | @res; | |||||||||||||||||||||||||||||||||||||||||
| 995 | 5 | }, 'ANY'; | |||||||||||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | sub makeAnyElement | ||||||||||||||||||||||||||||||||||||||||||
| 999 | 5 | ▶ | { my ($self, $path, $handler, $yes, $no, $process, $min, $max) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeAnyElement: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 5 | ▶ | my %yes = map +($_ => 1), @{$yes || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$yes || []
MC/DC100%1/1
$yes || []
$yes
Truth table100%2/2
A
A= $yes
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 5 | ▶ | my %no = map +($_ => 1), @{$no || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$no || []
MC/DC100%1/1
$no || []
$no
Truth table100%2/2
A
A= $no
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 5 | my $prefs = $self->{prefixes}; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 5 | ▶ | $handler ||= 'SKIP_ALL'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$handler ||= "SKIP_ALL"
MC/DC100%1/1
$handler ||= "SKIP_ALL"
$handler
Truth table100%2/2
A
A= $handler
| |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 5 | weaken $self; | |||||||||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||||||||||
| 1007 | bless | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | 5 | ▶ | sub { my ($doc, $values) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=19 SCAR=30.2
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | 5 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | 5 | foreach my $label (sort keys %$values) | |||||||||||||||||||||||||||||||||||||||||
| 1012 | 17 | { my ($type, $ns, $local); | |||||||||||||||||||||||||||||||||||||||||
| 1013 | 17 | ▶ | if(substr($label, 0, 1) eq '{') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1014 | 10 | { ($ns, $local) = unpack_type $label; | |||||||||||||||||||||||||||||||||||||||||
| 1015 | 10 | $type = $label; | |||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | elsif(index($label, ':') >= 0) | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | 2 | { (my $prefix, $local) = split ':', $label, 2; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | 2 | ▶ | my $match = first {$_->{prefix} eq $prefix} values %$prefs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1020 | 2 | ▶ | $ns = $match ? $match->{uri} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 2 | $type = pack_type $ns, $local; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | 5 | else {next} # not fully qualified, not an 'any' | |||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 12 | ▶ | $yes{$ns} or next if keys %yes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
keys %yes && ($yes{$ns} || (next))
$yes{$ns} or next
MC/DC0%0/2
keys %yes && ($yes{$ns} || (next))
keys %yes
$yes{$ns}
Truth table66%2/3
A && B
A= keys %yesB= $yes{$ns}
| |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 10 | ▶ | $no{$ns} and next if keys %no; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
keys %no && ($no{$ns} && (next))
$no{$ns} and next
MC/DC0%0/2
keys %no && ($no{$ns} && (next))
keys %no
$no{$ns}
Truth table66%2/3
A && B
A= keys %noB= $no{$ns}
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 8 | ▶ | my $value = delete $values->{$label} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 8 | my ($attrs, $elems) = _split_any_list $path, $type, $value; | |||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||
| 1031 | 8 | ▶ | $values->{$type} = $attrs if @$attrs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 8 | ▶ | @$elems or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | 2 | foreach my $node (@$elems) | |||||||||||||||||||||||||||||||||||||||||
| 1035 | 2 | { my $nodens = $node->namespaceURI; | |||||||||||||||||||||||||||||||||||||||||
| 1036 | 2 | ▶ | defined $nodens or next; # see README.todo work-around | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 2 | my $nodetype = type_of_node $node; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 2 | ▶ | next if $nodetype eq $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | error __x"provided 'any' element node has type {type}, but labeled with {other} at {path}" | |||||||||||||||||||||||||||||||||||||||||
| 1042 | , type => $nodetype, other => $type, path => $path | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 2 | push @res, @$elems; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | 2 | ▶ | $max eq 'unbounded' || @res <= $max | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$max eq "unbounded" or @res <= $max
MC/DC0%0/2
$max eq "unbounded" or @res <= $max
$max eq "unbounded"
@res <= $max
Truth table33%1/3
A or B
A= $max eq "unbounded"B= @res <= $max
| |||||||||||||||||||||||||||||||||||||||||||
| 1047 | or error __x"too many 'any' elements after consuming {count} nodes of {type}, max {max} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | , count => scalar @$elems, type => $type | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | , max => $max, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||
| 1052 | 5 | ▶ | @res >= $min | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1053 | or error __x"too few 'any' elements, got {count} for minimum {min} at {path}" | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | , count => scalar @res, min => $min, path => $path; | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | 5 | ▶ | @res ? @res : undef; # empty, then "0 but true" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1057 | 5 | }, 'ANY'; | |||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||
| 1060 | # xsi:type handling | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | sub makeXsiTypeSwitch($$$$) | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | 3 | ▶ | { my ($self, $where, $elem, $default_type, $types) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeXsiTypeSwitch: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1064 | 3 | my $xsi = $self->_registerNSprefix(xsi => SCHEMA2001i, 1) . ':type'; | |||||||||||||||||||||||||||||||||||||||||
| 1065 | 3 | my %types; | |||||||||||||||||||||||||||||||||||||||||
| 1066 | 3 | foreach my $type (sort keys %$types) | |||||||||||||||||||||||||||||||||||||||||
| 1067 | 6 | { my ($ns, $local) = unpack_type $type; | |||||||||||||||||||||||||||||||||||||||||
| 1068 | 6 | my $tag = $self->makeTagQualified($where, undef, $local, $ns); | |||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | # register code under both prefixed and full type name | ||||||||||||||||||||||||||||||||||||||||||
| 1071 | 6 | $types{$self->prefixed($type)} = $types{$type} = [$tag,$types->{$type}]; | |||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | 6 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1075 | 6 | my ($doc, $values) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | ref $values eq 'HASH' && $values->{XSI_TYPE} | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | 6 | ▶ | or return $types{$default_type}[1]->(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $values eq "HASH" and $values->{"XSI_TYPE"}
MC/DC0%0/2
ref $values eq "HASH" and $values->{"XSI_TYPE"}
ref $values eq "HASH"
$values->{"XSI_TYPE"}
Truth table33%1/3
A and B
A= ref $values eq "HASH"B= $values->{"XSI_TYPE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||
| 1079 | 6 | my %v = %$values; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | 6 | my $type = delete $v{XSI_TYPE}; | |||||||||||||||||||||||||||||||||||||||||
| 1081 | 6 | ▶ | my $def = $types{$type} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1082 | or error __x"specified xsi:type list for `{default}' does not contain `{got}'" | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | , default => $default_type, got => $type; | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||
| 1085 | 6 | my ($t, $code) = @$def; | |||||||||||||||||||||||||||||||||||||||||
| 1086 | 6 | ▶ | my $node = $code->($doc, \%v) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | 6 | $node->setAttribute($xsi, $t); | |||||||||||||||||||||||||||||||||||||||||
| 1089 | 6 | $node; | |||||||||||||||||||||||||||||||||||||||||
| 1090 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||
| 1093 | sub makeHook($$$$$$$) | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | 9 | ▶ | { my ($self, $path, $r, $tag, $before, $replace, $after, $fulltype) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeHook: called CC=9 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 9 | ▶ | return $r unless $before || $replace || $after; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$before or $replace or $after
$before or $replace
MC/DC0%0/3
$before or $replace or $after
$before
$replace
$after
Truth table75%3/4
A or B or C
A= $beforeB= $replaceC= $after
| |||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 9 | my $do_replace; | |||||||||||||||||||||||||||||||||||||||||
| 1098 | 9 | ▶ | if($replace) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 1 | ▶ | { return sub {()} if grep $_ eq 'SKIP', @$replace; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | # Input for replace is Perl, output is XML... so we cannot stack them | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | ▶ | error __x"writer only supports one replace hook (for {type})" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1103 | , type => $fulltype | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | if @$replace > 1; | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $do_replace = $self->_decodeReplace($path, $replace->[0]); | |||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | 8 | ▶ | my @do_before = $before ? map $self->_decodeBefore($path,$_), @$before :(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 8 | ▶ | my @do_after = $after ? map $self->_decodeAfter($path,$_), @$after :(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | sub | ||||||||||||||||||||||||||||||||||||||||||
| 1113 | 8 | ▶ | { my ($doc, $val) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1114 | 8 | ▶ | defined $val or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 8 | foreach (@do_before) | |||||||||||||||||||||||||||||||||||||||||
| 1116 | 6 | { $val = $_->($doc, $val, $path, $fulltype); | |||||||||||||||||||||||||||||||||||||||||
| 1117 | 6 | ▶ | defined $val or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 8 | ▶ | my $xml = $do_replace | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | ? $do_replace->($doc, $val, $path, $tag, $r, $fulltype) | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | : $r->($doc, $val); | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | 8 | ▶ | defined $xml or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 8 | foreach (@do_after) | |||||||||||||||||||||||||||||||||||||||||
| 1126 | 5 | { $xml = $_->($doc, $xml, $path, $val, $fulltype); | |||||||||||||||||||||||||||||||||||||||||
| 1127 | 5 | ▶ | defined $xml or return (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 8 | $xml; | |||||||||||||||||||||||||||||||||||||||||
| 1131 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||||||||||||||||
| 1134 | sub _decodeBefore($$) | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | 6 | ▶ | { my ($self, $path, $call) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decodeBefore: called CC=3 SCAR=17.3
| |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 6 | ▶ | return $call if ref $call eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | # $code->($doc, $values, $path) | ||||||||||||||||||||||||||||||||||||||||||
| 1139 | 0 | ▶ | $call eq 'PRINT_PATH' ? sub { print "$_[2]\n"; $_[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | : error __x"labeled before hook `{name}' undefined for WRITER", name=>$call; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | sub _decodeReplace($$) | ||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | ▶ | { my ($self, $path, $call) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decodeReplace: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | ▶ | return $call if ref $call eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||
| 1147 | # SKIP already handled | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | # $replace->($doc, $val, $path, $tag, $replaced) | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | error __x"labeled replace hook `{name}' undefined for WRITER", name=>$call; | |||||||||||||||||||||||||||||||||||||||||
| 1150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | |||||||||||||||||||||||||||||||||||||||||||
| 1152 | sub _decodeAfter($$) | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | 5 | ▶ | { my ($self, $path, $call) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decodeAfter: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1154 | 5 | ▶ | return $call if ref $call eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||||||||||
| 1156 | 1 | ▶ | $call eq 'PRINT_PATH' ? sub { print "$_[2]\n"; $_[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 1 | ▶ | : error __x"labeled after hook `{name}' undefined for WRITER", name=>$call; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||||||||||||||||
| 1160 | sub makeBlocked($$$) | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | 19 | ▶ | { my ($self, $where, $class, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeBlocked: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1162 | 19 | my $err_type = $self->prefixed($type); | |||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | # errors are produced in class=misfit to allow other choices to succeed. | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | $class eq 'anyType' | ||||||||||||||||||||||||||||||||||||||||||
| 1166 | 4 | ▶ | ? { st => sub { error __x"use of `{type}' blocked at {where}" | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1167 | , type => $err_type, where => $where, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | }} | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | : $class eq 'simpleType' | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | 2 | ▶ | ? { st => sub { error __x"use of {class} `{type}' blocked at {where}" | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1171 | , class => $class, type => $err_type, where => $where | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | , _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 1173 | }} | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | : $class eq 'complexType' | ||||||||||||||||||||||||||||||||||||||||||
| 1175 | ? { elems => [] } | ||||||||||||||||||||||||||||||||||||||||||
| 1176 | : $class eq 'ref' | ||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | ▶ | ? { st => sub { error __x"use of referenced `{type}' blocked at {where}" | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1178 | , type => $err_type, where => $where, _class => 'misfit'; | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | }} | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | 19 | ▶ | : panic "blocking of $class for $type not implemented"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | sub addTypeAttribute($$) | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | 1 | ▶ | { my ($self, $type, $do) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addTypeAttribute: called CC=1 SCAR=0.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 1 | my $xsi = $self->_registerNSprefix(xsi => SCHEMA2001i, 1) . ':type'; | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 1 | my $xsd = $self->_registerNSprefix(xsd => SCHEMA2001, 1); | |||||||||||||||||||||||||||||||||||||||||
| 1187 | 1 | my $typed = $self->prefixed($type); | |||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 1 | my $r = $do->(@_); | |||||||||||||||||||||||||||||||||||||||||
| 1191 | 1 | ▶ | $type && $r && UNIVERSAL::isa($r, 'XML::LibXML::Element') or return $r; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$type and $r and UNIVERSAL::isa($r, "XML::LibXML::Element")
$type and $r
MC/DC0%0/3
$type and $r and UNIVERSAL::isa($r, "XML::LibXML::Element")
$type
$r
UNIVERSAL::isa($r, "XML::LibXML::Element")
Truth table25%1/4
A and B and C
A= $typeB= $rC= UNIVERSAL::isa($r, "XML::LibXML::Element")
| |||||||||||||||||||||||||||||||||||||||||||
| 1192 | 1 | ▶ | return $r if $r->getAttributeNS(SCHEMA2001i, 'type'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 1 | $r->setAttribute($xsi, $typed); | |||||||||||||||||||||||||||||||||||||||||
| 1194 | 1 | $r; | |||||||||||||||||||||||||||||||||||||||||
| 1195 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||
| 1198 | #------------ | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | 47 | 1; | |||||||||||||||||||||||||||||||||||||||||