| 1 | package SOAP::WSDL::XSD::Element; | ||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Class::Std::Fast::Storable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use base qw(SOAP::WSDL::Base); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | our $VERSION = 3.004; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # id provided by Base | ||||||||||||||||||||||||||||
| 10 | # name provided by Base | ||||||||||||||||||||||||||||
| 11 | # annotation provided by Base | ||||||||||||||||||||||||||||
| 12 | 2 | my %simpleType_of :ATTR(:name<simpleType> :default<()>); | |||||||||||||||||||||||||||
| 13 | 2 | my %complexType_of :ATTR(:name<complexType> :default<()>); | |||||||||||||||||||||||||||
| 14 | 2 | my %facet_of :ATTR(:name<facet> :default<()>); | |||||||||||||||||||||||||||
| 15 | 2 | my %type_of :ATTR(:name<type> :default<()>); | |||||||||||||||||||||||||||
| 16 | 2 | my %abstract_of :ATTR(:name<abstract> :default<()>); | |||||||||||||||||||||||||||
| 17 | 2 | my %block_of :ATTR(:name<block> :default<()>); | |||||||||||||||||||||||||||
| 18 | 2 | my %default_of :ATTR(:name<default> :default<()>); | |||||||||||||||||||||||||||
| 19 | 2 | my %final_of :ATTR(:name<final> :default<()>); | |||||||||||||||||||||||||||
| 20 | 2 | my %fixed_of :ATTR(:name<fixed> :default<()>); | |||||||||||||||||||||||||||
| 21 | 2 | my %form_of :ATTR(:name<form> :default<()>); | |||||||||||||||||||||||||||
| 22 | 2 | my %maxOccurs_of :ATTR(:name<maxOccurs> :default<()>); | |||||||||||||||||||||||||||
| 23 | 2 | my %minOccurs_of :ATTR(:name<minOccurs> :default<()>); | |||||||||||||||||||||||||||
| 24 | 2 | my %nillable_of :ATTR(:name<nillable> :default<()>); | |||||||||||||||||||||||||||
| 25 | 2 | my %ref_of :ATTR(:name<ref> :default<()>); | |||||||||||||||||||||||||||
| 26 | 2 | my %substitutionGroup_of :ATTR(:name<substitutionGroup> :default<()>); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 11 | ▶ | sub first_simpleType { | ||||||||||||||||||||||||||
|
Subroutine
first_simpleType: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 11 | my $result_ref = $simpleType_of{ ident shift }; | |||||||||||||||||||||||||||
| 30 | 11 | ▶ | return if not $result_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 10 | ▶ | return $result_ref if (not ref $result_ref eq 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 7 | return $result_ref->[0]; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 3 | ▶ | sub first_complexType { | ||||||||||||||||||||||||||
|
Subroutine
first_complexType: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 3 | my $result_ref = $complexType_of{ ident shift }; | |||||||||||||||||||||||||||
| 37 | 3 | ▶ | return if not $result_ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 2 | ▶ | return $result_ref if (not ref $result_ref eq 'ARRAY'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 1 | return $result_ref->[0]; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # serialize type instead... | ||||||||||||||||||||||||||||
| 43 | 9 | ▶ | sub serialize { | ||||||||||||||||||||||||||
|
Subroutine
serialize: called CC=16 SCAR=36.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 9 | my ($self, $name, $value, $opt) = @_; | |||||||||||||||||||||||||||
| 45 | 9 | my $type; | |||||||||||||||||||||||||||
| 46 | 9 | my $typelib = $opt->{ typelib }; | |||||||||||||||||||||||||||
| 47 | 9 | my %ns_map = %{ $opt->{ namespace } }; | |||||||||||||||||||||||||||
| 48 | 9 | my $ident = ident $self; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # abstract elements may only be serialized via ref - and then we have a | ||||||||||||||||||||||||||||
| 51 | # name... | ||||||||||||||||||||||||||||
| 52 | 9 | ▶ | die "cannot serialize abstract element" if $abstract_of{ $ident } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$abstract_of{$ident} and not $name
MC/DC100%2/2
$abstract_of{$ident} and not $name
$abstract_of{$ident}
not $name
Truth table100%3/3
A and not(B)
A= $abstract_of{$ident}B= not $name
| |||||||||||||||||||||||||||||
| 53 | and not $name; | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # TODO: implement final and substitutionGroup - maybe never implement | ||||||||||||||||||||||||||||
| 56 | # substitutionGroup ? | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 8 | ▶ | $name = $self->get_name() if not ($name); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 8 | ▶ | if ( $opt->{ qualify } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 2 | $opt->{ attributes } = [ ' xmlns="' . $self->get_targetNamespace .'"' ]; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # set default and fixed - fixed overrides everything, | ||||||||||||||||||||||||||||
| 66 | # default only empty (undefined) values | ||||||||||||||||||||||||||||
| 67 | 8 | ▶ | if (not defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 6 | ▶ | $value = $default_of{ ident $self } if $default_of{ ident $self }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | 8 | ▶ | $value = $fixed_of{ ident $self } if $fixed_of{ ident $self }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # TODO check nillable and serialize empty data correctly | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # return if minOccurs is 0 and we have no value | ||||||||||||||||||||||||||||
| 75 | 8 | ▶ | if (defined $minOccurs_of{ ident $self } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $minOccurs_of{&ident($self)} and $minOccurs_of{&ident($self)} == 0
MC/DC0%0/2
defined $minOccurs_of{&ident($self)} and $minOccurs_of{&ident($self)} == 0
defined $minOccurs_of{&ident($self)}
$minOccurs_of{&ident($self)} == 0
Truth table33%1/3
A and B
A= defined $minOccurs_of{&ident($self)}B= $minOccurs_of{&ident($self)} == 0
| |||||||||||||||||||||||||||||
| 76 | and $minOccurs_of{ ident $self } == 0) { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return q{} if not defined $value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | # handle direct simpleType and complexType here | ||||||||||||||||||||||||||||
| 81 | 8 | ▶ | if ($type = $self->first_simpleType() ) { # simpleType | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 82 | 8 | return $type->serialize( $name, $value, $opt ); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | elsif ($type = $self->first_complexType() ) { # complexType | ||||||||||||||||||||||||||||
| 85 | 0 | return $type->serialize( $name, $value, $opt ); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | elsif (my $ref_name = $ref_of{ $ident }) { # ref | ||||||||||||||||||||||||||||
| 88 | 0 | my ($prefix, $localname) = split /:/ , $ref_name; | |||||||||||||||||||||||||||
| 89 | 0 | my $ns = $ns_map{ $prefix }; | |||||||||||||||||||||||||||
| 90 | 0 | $type = $typelib->find_element( $ns, $localname ); | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | die "no element for ref $prefix:$localname" if (not $type); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | return $type->serialize( $name, $value, $opt ); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | # lookup type | ||||||||||||||||||||||||||||
| 96 | 0 | my ($prefix, $localname) = split /:/ , $self->get_type(); | |||||||||||||||||||||||||||
| 97 | 0 | my $ns = $ns_map{ $prefix }; | |||||||||||||||||||||||||||
| 98 | 0 | $type = $typelib->find_type( | |||||||||||||||||||||||||||
| 99 | $ns, $localname | ||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # safety check | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | die "no type for $prefix:$localname $ns_map{$prefix}" if (not $type); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | return $type->serialize( $name, $value, $opt ); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 2 | 1; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||