lib/SOAP/WSDL/XSD/Typelib/ComplexType.pm

filter: Statementstmt 95.2% 182 / 191 Branchbran 89.5% 77 / 86 Conditioncond 73.0% 19 / 26 MC/DCmcdc 50.0% 8 / 16 Subroutinesub 96.0% 24 / 25 Podpod 66.6% 4 / 6 totaltotal 89.7% 314 / 350 CC 54 SCAR 20.5
CC
54
Cov
92%
__ANON__
16.8
__ANON__
12.2
as_hash_ref
11.0
CRAP 7.8
« blib/lib/SOAP/WSDL/Factory/Transport.pm ↑ Summary blib/lib/SOAP/WSDL/Types.pm »
1 #!/usr/bin/perl
2 package SOAP::WSDL::XSD::Typelib::ComplexType;
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use SOAP::WSDL::XSD::Typelib::Builtin;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 require Class::Std::Fast::Storable;
10 13 ▶use Class::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 ▶use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anyType);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 13 our $VERSION = 3.004;
15  
16 # remove in 2.1
17 13 our $AS_HASH_REF_WITHOUT_ATTRIBUTES = 0;
18  
19 13 my %ELEMENT_FORM_QUALIFIED_OF; # denotes whether elements are qualified
20 my %ELEMENTS_FROM; # order of elements in a class
21 13 my %ATTRIBUTES_OF; # references to value hashes
22 13 my %CLASSES_OF; # class names of elements in a class
23 13 my %NAMES_OF; # XML names of elements in a class
24  
25  
26 # XML Attribute handling
27 13 my %xml_attr_of :ATTR();
28  
29 # Namespace handling
30 13 my %xmlns_of :ATTR();
31  
32 # don't you ever dare to use this !
33 13 our $___attributes_of_ref = \%ATTRIBUTES_OF;
34 13 our $___xml_attribute_of_ref = \%xml_attr_of;
35  
36 # STORABLE_ methods for supporting Class::Std::Fast::Storable.
37 # We could also handle them via AUTOMETHOD,
38 # but AUTOMETHOD should always croak...
39 # Actually, AUTOMETHOD is faster (~1%) if Class::Std::Fast is loaded
40 # properly, and slower (~10%) if not.
41 # Hmmm. Trade 1% for 10?
42  
43 13 my %STORABLE_METHODS = (
44 STORABLE_freeze_pre => undef,
45 STORABLE_freeze_post => undef,
46 STORABLE_thaw_pre => undef,
47 STORABLE_thaw_post => undef,
48 );
49  
50 # for error reporting. Eases working with data objects...
51 16 ▶sub AUTOMETHOD {
Subroutine AUTOMETHOD: called CC=5 SCAR=16.1
Pod undocumented
52 # return before unpacking @_ for speed reasons
53 16 ▶ return if exists $STORABLE_METHODS{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $STORABLE_METHODS{$_} 0 16 16
54  
55 16 my ($self, $ident, @args_from) = @_;
56 16 ▶ my $class = ref $self || $self or die "Cannot call AUTOMETHOD as function";
Branch: 1 branch
BranchTrueFalseTotal
my $class = ref $self || $self or die "Cannot call AUTOMETHOD as function" 15 1 16
Condition100%3/3
ref $self || $self
l!l&&r!l&&!r
1051
MC/DC100%2/2
ref $self || $self
ref $self $self
Truth table100%3/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
57  
58 # Test whether we're called from ->can()
59 15 my @caller = caller(1);
60  
61 # return if not called by AUTOLOAD - caller must be something like can()
62 # Unfortunately we cannot test for "UNIVERSAL::can", as it gets overwritten
63 # by both Class::Std and Class::Std::Fast, and we don't know the loading
64 # order (Class::Std::Fast should be loaded before for maximum speedup)
65 15 ▶ return if $caller[3] ne 'Class::Std::AUTOLOAD';
Branch: 1 branch
BranchTrueFalseTotal
if $caller[3] ne "Class::Std::AUTOLOAD" 12 3 15
66  
67 confess "Can't locate object method \"$_\" via package \"$class\". \n"
68 . "Valid methods are: "
69 3 . join(', ', map { ("get_$_" , "set_$_") } keys %{ $ATTRIBUTES_OF{ $class } })
70 . "\n"
71 }
72  
73 11 ▶sub attr {
Subroutine attr: called CC=4 SCAR=13.9
Pod documented
74 # We're working on @_ for speed.
75 # Normally, the first line would look like this:
76 # my $self = shift;
77  
78 11 ▶ my $class = $_[0]->__get_attr_class()
Branch: 1 branch
BranchTrueFalseTotal
my $class = $_[0]->__get_attr_class or return 10 1 11
79 or return;
80  
81 # pass arguments to attributes constructor (if any);
82 # lets attr($foo) work as setter
83 10 ▶ if ($_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1]) 3 7 10
84 3 return $xml_attr_of{ ${$_[0]} } = $class->new($_[1]);
85 }
86 7 ▶ return $xml_attr_of{ ${$_[0]} } if exists $xml_attr_of{ ${$_[0]} };
Branch: 1 branch
BranchTrueFalseTotal
if exists $xml_attr_of{${$_[0];}} 5 2 7
87 2 return $xml_attr_of{ ${$_[0]} } = $class->new();
88 }
89  
90 14 ▶sub serialize_attr {
Subroutine serialize_attr: called CC=2 SCAR=6.9
Pod documented
91 14 ▶ return q{} if not $xml_attr_of{ ${ $_[0] } };
Branch: 1 branch
BranchTrueFalseTotal
unless $xml_attr_of{${$_[0];}} 11 3 14
92 3 return $xml_attr_of{ ${ $_[0] } }->serialize();
93 }
94  
95 # TODO: are complextypes are always true ?
96 13 ▶sub as_bool :BOOLIFY { 1 }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine as_bool: called CC=1 SCAR=0.0
Pod documented
97  
98 21 ▶sub as_hash_ref {
Subroutine as_hash_ref: called CC=11 SCAR=24.0
Pod documented
99 # we're working on $_[0] for speed (as always...)
100 #
101 # Normally the first line would read:
102 # my ($self, $ignore_attributes) = @_;
103 #
104 21 my $attributes_ref = $ATTRIBUTES_OF{ ref $_[0] };
105  
106 21 my $hash_of_ref = {};
107 21 ▶ if ($_[0]->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')) { } 4 17 21
108 4 $hash_of_ref->{ value } = $_[0]->get_value();
109 }
110 else {
111 17 foreach my $attribute (keys %{ $attributes_ref }) {
112 18 ▶ next if not defined $attributes_ref->{ $attribute }->{ ${ $_[0] } };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $attributes_ref->{$attribute}{${$_[0];}} 1 17 18
113 17 my $value = $attributes_ref->{ $attribute }->{ ${ $_[0] } };
114  
115 $hash_of_ref->{ $attribute } = blessed $value
116 ? $value->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')
117 ? $value->get_value()
118 : $value->as_hash_ref($_[1])
119 : ref $value eq 'ARRAY'
120 ? [
121 map {
122 10 ▶ $_->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType')
Branch: 1 branch
BranchTrueFalseTotal
$_->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType') ? : 8 2 10
123 ? $_->get_value()
124 : $_->as_hash_ref($_[1])
125 17 ▶ } @{ $value }
Branch: 3 branches
BranchTrueFalseTotal
builtin::blessed($value) ? : 12 5 17
$value->isa('SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType') ? : 11 1 12
ref $value eq 'ARRAY' ? : 5 0 5
126 ]
127 : die "Neither blessed obj nor list ref";
128 };
129 }
130  
131 # $AS_HASH_REF_WITHOUT_ATTRIBUTES is deprecated by NOW and will be removed
132 # in 2.1
133 21 ▶ return $hash_of_ref if $_[1] or $AS_HASH_REF_WITHOUT_ATTRIBUTES;
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] or $SOAP::WSDL::XSD::Typelib::ComplexType::AS_HASH_REF_WITHOUT_ATTRIBUTES 3 18 21
Condition100%3/3
$_[1] or $SOAP::WSDL::XSD::Typelib::ComplexType::AS_HASH_REF_WITHOUT_ATTRIBUTES
l!l&&r!l&&!r
2118
MC/DC100%2/2
$_[1] or $SOAP::WSDL::XSD::Typelib::ComplexType::AS_HASH_REF_WITHOUT_ATTRIBUTES
$_[1] $SOAP::WSDL::XSD::Typelib::ComplexType::AS_HASH_REF_WITHOUT_ATTRIBUTES
Truth table100%3/3
A or B
A= $_[1]B= $SOAP::WSDL::XSD::Typelib::ComplexType::AS_HASH_REF_WITHOUT_ATTRIBUTES
ABresult
1X1
011
000
134  
135  
136 18 ▶ if (exists $xml_attr_of{ ${ $_[0] } }) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $xml_attr_of{${$_[0];}}) 5 13 18
137 5 $hash_of_ref->{ xmlattr } = $xml_attr_of{ ${ $_[0] } }->as_hash_ref();
138 }
139  
140 18 return $hash_of_ref;
141 }
142  
143 # we store per-class elements.
144 # call as __PACKAGE__->_factory
145 33 ▶sub _factory {
Subroutine _factory: called CC=6 SCAR=18.0
146 33 my $class = shift;
147 33 $ELEMENTS_FROM{ $class } = shift;
148 33 $ATTRIBUTES_OF{ $class } = shift;
149 33 $CLASSES_OF{ $class } = shift;
150 33 $NAMES_OF{ $class } = shift;
151  
152 13 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
153 13 ▶ no warnings qw(redefine);
Subroutine BEGIN: called CC=1 SCAR=0.0
154  
155 33 ▶ while (my ($name, $attribute_ref) = each %{ $ATTRIBUTES_OF{ $class } } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$ATTRIBUTES_OF{$class};}) 69 31 100
156 69 ▶ my $type = $CLASSES_OF{ $class }->{ $name }
Branch: 1 branch
BranchTrueFalseTotal
my $type = $CLASSES_OF{$class}{$name} or croak("No class given for $name") 68 1 69
157 or croak "No class given for $name";
158  
159 # require all types here
160 Class::Load::is_class_loaded($type)
161 68 ▶ or eval { Class::Load::load_class $type }
Branch: 1 branch
BranchTrueFalseTotal
Class::Load::is_class_loaded($type) or eval { do { Class::Load::load_class($type) } } or croak($@) 67 1 68
Condition100%3/3
Class::Load::is_class_loaded($type) or eval { do { Class::Load::load_class($type) } }
l!l&&r!l&&!r
6611
MC/DC100%2/2
Class::Load::is_class_loaded($type) or eval { do { Class::Load::load_class($type) } }
Class::Load::is_class_loaded($type) eval { do { Class::Load::load_class($type) } }
Truth table100%3/3
A or B
A= Class::Load::is_class_loaded($type)B= eval { do { Class::Load::load_class($type) } }
ABresult
1X1
011
000
162 or croak $@;
163  
164 # check now, so we don't need to do it later.
165 # $is_list is used in the methods created. Filling it now means
166 # we don't have to check it every time the method is called, but
167 # can just use $is_list, which will hold the value assigned to
168 # it when the method was created.
169 67 my $is_list = $type->isa('SOAP::WSDL::XSD::Typelib::Builtin::list');
170  
171 # The set_$name method below looks rather weird,
172 # but is optimized for performance.
173 #
174 # We could use sub calls for sure, but these are much slower. And
175 # the logic is not that easy:
176 #
177 # we accept:
178 # a) objects
179 # b) scalars
180 # c) list refs
181 # d) hash refs
182 # e) mixed stuff of all of the above, so we have to set our child to
183 # a) value if it's an object
184 # b) New object of expected class with value for simple values
185 # c 1) New object with value for list values and list type
186 # c 2) List ref of new objects with value for list values and
187 # non-list type
188 # c + e 1) List ref of objects for list values (list of objects)
189 # and non-list type
190 # c + e 2) List ref of new objects for list values (list of hashes)
191 # and non-list type where the hash ref is passed to new as
192 # argument
193 # d) New object with values passed to new for HASH references
194 #
195 # We throw an error on
196 # a) list refs of list refs - don't know what to do with this (maybe
197 # use for lists of list types ?)
198 # b) wrong object types
199 # c) non-blessed non-ARRAY/HASH references - if you can define semantics
200 # for GLOB or SCALAR references, feel free to add them.
201 # d) we should also die for non-blessed non-ARRAY/HASH references in
202 # lists but don't do yet - oh my !
203  
204 # keep in sync with Generator::Template::Plugin::XSD - maybe use
205 # function to allow substituting via symbol table...
206 67 my $method_name = $name;
207 67 $method_name =~s{[\.\-]}{_}xmsg;
208 67 ▶ *{ "$class\::set_$method_name" } = sub {
Subroutine __ANON__: called CC=12 SCAR=25.0
209 36 ▶ if (not $#_) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($#_) 1 35 36
210 1 delete $attribute_ref->{ ${ $_[0] } };
211 1 return;
212 };
213 35 my $is_ref = ref $_[1];
214 33 $attribute_ref->{ ${ $_[0] } } = ($is_ref)
215 ? ($is_ref eq 'ARRAY')
216 ? $is_list # remembered from outside closure
217 ? $type->new({ value => $_[1] }) # it's a list element - can take list ref as value
218 : [ map { # it's not a list element - set value to list of objects
219 14 ▶ ref $_
Branch: 3 branches
BranchTrueFalseTotal
ref $_ ? : 8 6 14
ref $_ eq 'HASH' ? : 0 8 8
ref $_ eq $type ? : 7 1 8
220 ? ref $_ eq 'HASH'
221 ? $type->new($_)
222 : ref $_ eq $type
223 ? $_
224 : croak "cannot use " . ref($_) . " reference as value for $name - $type required"
225 : $type->new({ value => $_ })
226 35 ▶ } @{ $_[1] }
Branch: 6 branches
BranchTrueFalseTotal
$is_ref ? : 13 22 35
$is_ref eq 'ARRAY' ? : 7 6 13
$is_list ? : 0 7 7
$is_ref eq 'HASH' ? : 2 4 6
builtin::blessed($_[1]) && $_[1]->isa($type) ? : 3 1 4
defined $_[1] ? : 22 0 22
Condition66%2/3
builtin::blessed($_[1]) and $_[1]->isa($type)
!ll&&!rl&&r
103
MC/DC50%1/2
builtin::blessed($_[1]) and $_[1]->isa($type)
builtin::blessed($_[1]) $_[1]->isa($type)
Truth table66%2/3
A and B
A= builtin::blessed($_[1])B= $_[1]->isa($type)
ABresult
0X0
100
111
227 ]
228 : $is_ref eq 'HASH'
229 ? $type->new( $_[1] )
230 # neither ARRAY nor HASH - probably an object... -
231 # do we need to test for it being blessed?
232 : blessed $_[1] && $_[1]->isa($type) # of required type ?
233 ? $_[1] # use it
234 : die croak "cannot use $is_ref reference as value for $name - $type required"
235  
236 # not $is_ref
237 : defined $_[1] ? $type->new({ value => $_[1] }) : () ;
238 33 return;
239 67 };
240  
241 67 ▶ *{ "$class\::add_$method_name" } = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
242 12 ▶ warn "attempting to add empty value to " . ref $_[0]
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] 1 11 12
243 if not defined $_[1];
244  
245 # first call
246 # test for existance, not for definedness
247 12 ▶ if (not exists $attribute_ref->{ ${ $_[0]} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$attribute_ref{${$_[0];}}) 2 10 12
248 2 $attribute_ref->{ ${ $_[0]} } = $_[1];
249 2 return;
250 }
251  
252 10 ▶ if (not ref $attribute_ref->{ ${ $_[0]} } eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $$attribute_ref{${$_[0];}} eq "ARRAY") 2 8 10
253 # second call: listify previous value if it's no list and add current
254 2 $attribute_ref->{ ${ $_[0]} } = [ $attribute_ref->{ ${ $_[0]} }, $_[1] ];
255 2 return;
256 }
257  
258 # second and following: add to list
259 8 push @{ $attribute_ref->{ ${ $_[0]} } }, $_[1];
260 8 return;
261 67 };
262 }
263  
264 # TODO Could be moved as normal method into base class, e.g. here.
265 # Hmm. let's see...
266 31 ▶ *{ "$class\::new" } = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
267 # We're working on @_ for speed.
268 # Normally, the first line would look like this:
269 # my ($class, $args_of) = @_;
270 #
271 # The hanging side comment show you what would be there, then.
272  
273 # Read as:
274 # my $self = bless \(my $o = Class::Std::Fast::ID()), $class;
275 38 my $self = bless \(my $o = Class::Std::Fast::ID()), $_[0];
276  
277 # Set attributes if passed via { xmlattr => \%attributes }
278 #
279 # This works just because
280 # a) xmlattr cannot be used as valid XML identifier (it starts
281 # with "xml" which is banned by the XML schema standard)
282 # b) $o->attr($attribute_ref) passes $attribute_ref to the
283 # attribute object's constructor
284 # c) we are in the object's constructor here (which means that)
285 # no attributes object can have been legally constructed
286 # before.
287 38 ▶ if (exists $_[1]->{xmlattr}) { # $args_of->{xmlattr}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_[1]{"xmlattr"}) 1 37 38
288 1 $self->attr(delete $_[1]->{xmlattr});
289 }
290  
291 # iterate over keys of arguments
292 # and call set appropriate field in clase
293 map { ($ATTRIBUTES_OF{ $class }->{ $_ })
294 ? do {
295 33 my $method = "set_$_";
296  
297 # keep in sync with Generator::Template::Plugin::XSD - maybe use
298 # function to allow substituting via symbol table...
299 33 $method =~s{[\.\-]}{_}xmsg;
300  
301 33 ▶ $self->$method( $_[1]->{ $_ } ); # ( $args_of->{ $_ } );
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ / \A # beginning of string xmlns # xmlns /msx ? : 1 2 3
302 }
303 : $_ =~ m{ \A # beginning of string
304 xmlns # xmlns
305 }xms # get_elements is inlined for performance.
306 ? ()
307 36 ▶ : do {
Branch: 1 branch
BranchTrueFalseTotal
$ATTRIBUTES_OF{$class}{$_} ? : 33 3 36
308 croak "unknown field $_ in $class. Valid fields are:\n"
309 2 . join(', ', @{ $ELEMENTS_FROM{ $class } }) . "\n"
310 . "Structure given:\n" . Dumper @_ };
311 38 } keys %{ $_[1] }; # %$args_of;
312 34 return $self;
313 31 };
314  
315 # this _serialize method works fine for <all> and <sequence>
316 # complextypes, as well as for <restriction><all> or
317 # <restriction><sequence>, and attribute sets.
318 #
319 # But what about choice, extension ?
320 #
321 # Triggers XML attribute serialization if the options hash ref contains
322 # a attr element with a true value.
323 31 ▶ *{ "$class\::_serialize" } = sub {
Subroutine __ANON__: called CC=12 SCAR=28.2
324 31 my $ident = ${ $_[0] };
325 31 my $option_ref = $_[1];
326
327 # return concatenated return value of serialize call of all
328 # elements retrieved from get_elements expanding list refs.
329 return \join q{} , map {
330 41 my $element = $ATTRIBUTES_OF{ $class }->{ $_ }->{ $ident };
331  
332 # do we have some content
333 41 ▶ if (defined $element) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $element) { } 34 7 41
334 34 ▶ $element = [ $element ] if not ref $element eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $element eq "ARRAY" 22 12 34
335 # use || $_; for backward compatibility
336 34 ▶ my $name = $NAMES_OF{$class}->{$_} || $_;
Condition66%2/3
$NAMES_OF{$class}{$_} || $_
l!l&&r!l&&!r
4300
MC/DC0%0/2
$NAMES_OF{$class}{$_} || $_
$NAMES_OF{$class}{$_} $_
Truth table66%2/3
A || B
A= $NAMES_OF{$class}{$_}B= $_
ABresult
1X1
011
000
337 34 my $target_namespace = $_[0]->get_xmlns();
338 map {
339 # serialize element elements with their own serializer
340 # but name them like they're named here.
341 # TODO: check. element ref="" has a name???
342 56 ▶ if ( $_->isa( 'SOAP::WSDL::XSD::Typelib::Element' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->isa('SOAP::WSDL::XSD::Typelib::Element')) { } 13 43 56
343 # serialize elements of different namespaces
344 # with namespace declaration
345 13 ▶ ($target_namespace ne $_->get_xmlns())
Branch: 1 branch
BranchTrueFalseTotal
$target_namespace ne $_->get_xmlns ? : 6 7 13
346 ? $_->serialize({ name => $name, qualified => 1 })
347 : $_->serialize({ name => $name });
348 }
349 # serialize complextype elments (of other types) with their
350 # serializer, but add element tags around.
351 else {
352 # default for undef is true
353 43 ▶ if (! defined $ELEMENT_FORM_QUALIFIED_OF{ $class }
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $ELEMENT_FORM_QUALIFIED_OF{$class} or $ELEMENT_FORM_QUALIFIED_OF{$class}) { } 43 0 43
Condition33%1/3
not defined $ELEMENT_FORM_QUALIFIED_OF{$class} or $ELEMENT_FORM_QUALIFIED_OF{$class}
l!l&&r!l&&!r
4300
MC/DC0%0/2
not defined $ELEMENT_FORM_QUALIFIED_OF{$class} or $ELEMENT_FORM_QUALIFIED_OF{$class}
not defined $ELEMENT_FORM_QUALIFIED_OF{$class} $ELEMENT_FORM_QUALIFIED_OF{$class}
Truth table33%1/3
not(A) or B
A= not defined $ELEMENT_FORM_QUALIFIED_OF{$class}B= $ELEMENT_FORM_QUALIFIED_OF{$class}
ABresult
1X1
011
000
354 or $ELEMENT_FORM_QUALIFIED_OF{ $class }
355 ) {
356 # handle types from different namespaces
357 #
358 # serialize with last namespace put on stack
359 # if the last namespace is a change from the
360 # before-last
361 #
362 43 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (exists $option_ref->{'xmlns_stack'} and scalar @{$option_ref->{'xmlns_stack'};} >= 2 and $option_ref->{'xmlns_stack'}[-1] ne $option_ref->{'xmlns_stack'}[-2]) { } 0 43 43
Condition50%3/6
exists $option_ref->{"xmlns_stack"} and scalar @{$option_ref->{"xmlns_stack"};} >= 2 and $option_ref->{"xmlns_stack"}[-1] ne $option_ref->{"xmlns_stack"}[-2]
!ll&&!rl&&r
4300
exists $option_ref->{"xmlns_stack"} and scalar @{$option_ref->{"xmlns_stack"};} >= 2
!ll&&!rl&&r
4390
MC/DC0%0/3
exists $option_ref->{"xmlns_stack"} and scalar @{$option_ref->{"xmlns_stack"};} >= 2 and $option_ref->{"xmlns_stack"}[-1] ne $option_ref->{"xmlns_stack"}[-2]
exists $option_ref->{"xmlns_stack"} scalar @{$option_ref->{"xmlns_stack"};} >= 2 $option_ref->{"xmlns_stack"}[-1] ne $option_ref->{"xmlns_stack"}[-2]
Truth table50%2/4
A and B and C
A= exists $option_ref->{"xmlns_stack"}B= scalar @{$option_ref->{"xmlns_stack"};} >= 2C= $option_ref->{"xmlns_stack"}[-1] ne $option_ref->{"xmlns_stack"}[-2]
ABCresult
0XX0
10X0
1100
1111
363 exists $option_ref->{ xmlns_stack }
364 39 && (scalar @{ $option_ref->{ xmlns_stack } } >= 2)
365 && ($option_ref->{ xmlns_stack }->[-1] ne $option_ref->{ xmlns_stack }->[-2])) {
366 # warn "New namespace: ", $option_ref->{ xmlns_stack }->[-1];
367 join q{}, $_->start_tag({ name => $name ,
368 xmlns => $option_ref->{ xmlns_stack }->[-1],
369 0 %{ $option_ref } })
370 , $_->serialize($option_ref)
371 0 , $_->end_tag({ name => $name , %{ $option_ref } });
372 }
373 else {
374 43 join q{}, $_->start_tag({ name => $name , %{ $option_ref } })
375 , $_->serialize($option_ref)
376 43 , $_->end_tag({ name => $name , %{ $option_ref } });
377 }
378 }
379 else {
380 # in elementFormDefault="unqualified" mode,
381 # the serialize method has to set
382 # xmnlns="" on all elements inside a ComplexType
383 #
384 # Other serializers usually use prefixes
385 # for "unqualified" and just omit all prefixes
386 # for inner elements
387
388 # check whether we "had" a xmlns around
389 0 my $set_xmlns = delete $option_ref->{xmlns};
390
391 # serialize start tag with xmlns="" if out parent
392 # did not do that
393 join q{}, $_->start_tag({
394 name => $name,
395 0 ▶ %{ $option_ref },
Branch: 1 branch
BranchTrueFalseTotal
!defined($set_xmlns) ? : 0 0 0
396 (! defined $set_xmlns)
397 ? (xmlns => "")
398 : ()
399 })
400 # add xmlns = "" to child serialize options
401 # to avoid putting xmlns="" everywhere
402 0 , $_->serialize({ %{$option_ref}, xmlns => "" })
403 0 , $_->end_tag({ name => $name , %{ $option_ref } });
404 }
405 }
406 34 } @{ $element }
407 }
408 else {
409 7 q{};
410 }
411 31 } (@{ $ELEMENTS_FROM{ $class } });
412 31 };
413  
414 # put hidden complex serializer into class
415 # ... but not for AttributeSet classes
416 31 ▶ if ( ! $class->isa('SOAP::WSDL::XSD::Typelib::AttributeSet')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $class->isa("SOAP::WSDL::XSD::Typelib::AttributeSet")) 26 5 31
417 26 *{ "$class\::serialize" } = \&__serialize_complex;
418 };
419 }
420  
421 0 ▶sub _set_element_form_qualified {
Subroutine _set_element_form_qualified: not called CC=1 SCAR=6.9
422 0 $ELEMENT_FORM_QUALIFIED_OF{ $_[0] } = $_[1];
423 }
424  
425 # Just as fallback: return no attribute set class as default.
426 # Subclasses may override
427 1 ▶sub __get_attr_class {};
Subroutine __get_attr_class: called CC=1 SCAR=0.0
428  
429 # hidden complex serializer
430 27 ▶sub __serialize_complex {
Subroutine __serialize_complex: called CC=3 SCAR=11.0
431 # we work on @_ for performance.
432 27 ▶ $_[1] ||= {}; # $option_ref
Condition100%2/2
$_[1] ||= {}
l!l
189
MC/DC100%1/1
$_[1] ||= {}
$_[1]
Truth table100%2/2
A
A= $_[1]
Aresult
11
00
433
434 27 push @{ $_[1]->{ xmlns_stack } }, $_[0]->get_xmlns();
435
436 # get content first (pass by reference to avoid copying)
437 27 my $content_ref = $_[0]->_serialize($_[1]); # option_ref
438  
439 27 pop @{ $_[1]->{ xmlns_stack } };
440  
441 # do we have a empty element ?
442 6 return $_[0]->start_tag({ %{ $_[1] }, empty => 1 })
443 27 ▶ if not length ${ $content_ref };
Branch: 1 branch
BranchTrueFalseTotal
unless length ${$content_ref;} 6 21 27
444  
445 21 return join q{}, $_[0]->start_tag($_[1]), ${ $content_ref }, $_[0]->end_tag();
446 }
447  
448 35 ▶sub get_xmlns {
Subroutine get_xmlns: called CC=1 SCAR=0.0
Pod undocumented
449 35 return q{}
450 }
451  
452 13 1;
453  
454 __END__
« blib/lib/SOAP/WSDL/Factory/Transport.pm ↑ Summary blib/lib/SOAP/WSDL/Types.pm »