| 1 | package SOAP::WSDL::XSD::ComplexType; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Class::Std::Fast::Storable; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(SOAP::WSDL::Base); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | our $VERSION = 3.004; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # id provided by Base | ||||||||||||||||||||||||||||
| 11 | # name provided by Base | ||||||||||||||||||||||||||||
| 12 | # annotation provided by Base | ||||||||||||||||||||||||||||
| 13 | 1 | my %length_of :ATTR(:name<length> :default<[]>); | |||||||||||||||||||||||||||
| 14 | 1 | my %minLength_of :ATTR(:name<minLength> :default<[]>); | |||||||||||||||||||||||||||
| 15 | 1 | my %maxLength_of :ATTR(:name<maxLength> :default<[]>); | |||||||||||||||||||||||||||
| 16 | 1 | my %pattern_of :ATTR(:name<pattern> :default<[]>); | |||||||||||||||||||||||||||
| 17 | 1 | my %enumeration_of :ATTR(:name<enumeration> :default<[]>); | |||||||||||||||||||||||||||
| 18 | 1 | my %whiteSpace_of :ATTR(:name<whiteSpace> :default<[]>); | |||||||||||||||||||||||||||
| 19 | 1 | my %totalDigits_of :ATTR(:name<totalDigits> :default<[]>); | |||||||||||||||||||||||||||
| 20 | 1 | my %fractionDigits_of :ATTR(:name<fractionDigits> :default<[]>); | |||||||||||||||||||||||||||
| 21 | 1 | my %minExclusive :ATTR(:name<minExclusive> :default<[]>); | |||||||||||||||||||||||||||
| 22 | 1 | my %minInclusive :ATTR(:name<minInclusive> :default<[]>); | |||||||||||||||||||||||||||
| 23 | 1 | my %maxExclusive :ATTR(:name<maxExclusive> :default<[]>); | |||||||||||||||||||||||||||
| 24 | 1 | my %maxInclusive :ATTR(:name<maxInclusive> :default<[]>); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | my %attribute_of :ATTR(:name<attribute> :default<()>); | |||||||||||||||||||||||||||
| 28 | 1 | my %element_of :ATTR(:name<element> :default<[]>); | |||||||||||||||||||||||||||
| 29 | 1 | my %group_of :ATTR(:name<group> :default<()>); | |||||||||||||||||||||||||||
| 30 | 1 | my %variety_of :ATTR(:name<variety> :default<()>); | |||||||||||||||||||||||||||
| 31 | 1 | my %base_of :ATTR(:name<base> :default<()>); | |||||||||||||||||||||||||||
| 32 | 1 | my %itemType_of :ATTR(:name<itemType> :default<()>); | |||||||||||||||||||||||||||
| 33 | 1 | my %abstract_of :ATTR(:name<abstract> :default<()>); | |||||||||||||||||||||||||||
| 34 | 1 | my %final_of :ATTR(:name<final> :default<()>); | |||||||||||||||||||||||||||
| 35 | 1 | my %mixed_of :ATTR(:name<mixed> :default<()>); # default is false | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | my %derivation_of :ATTR(:name<derivation> :default<()>); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # is set to simpleContent/complexContent | ||||||||||||||||||||||||||||
| 40 | 1 | my %content_model_of :ATTR(:name<contentModel> :default<NONE>); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | sub get_flavor; *get_flavor = \&get_variety; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub push_element { | ||||||||||||||||||||||||||
|
Subroutine
push_element: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | 0 | my $element = shift; | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ($variety_of{ ident $self } eq 'all') | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | $element->set_minOccurs(0) if not defined ($element->get_minOccurs); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $element->set_maxOccurs(1) if not defined ($element->get_maxOccurs); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | elsif ($variety_of{ ident $self } eq 'sequence') | ||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $element->set_minOccurs(1) if not defined ($element->get_minOccurs); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $element->set_maxOccurs(1) if not defined ($element->get_maxOccurs); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | push @{ $element_of{ ident $self } }, $element; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub set_restriction { | ||||||||||||||||||||||||||
|
Subroutine
set_restriction: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 0 | my $element = shift; | |||||||||||||||||||||||||||
| 63 | 0 | $variety_of{ ident $self } = 'restriction'; | |||||||||||||||||||||||||||
| 64 | 0 | $derivation_of{ ident $self } = 'restriction'; | |||||||||||||||||||||||||||
| 65 | 0 | $base_of{ ident $self } = $element->{ Value }; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub set_extension { | ||||||||||||||||||||||||||
|
Subroutine
set_extension: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 0 | my $element = shift; | |||||||||||||||||||||||||||
| 71 | 0 | $variety_of{ ident $self } = 'extension'; | |||||||||||||||||||||||||||
| 72 | 0 | $derivation_of{ ident $self } = 'extension'; | |||||||||||||||||||||||||||
| 73 | 0 | $base_of{ ident $self } = $element->{ Value }; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 78 | 0 | my @args = @_; | |||||||||||||||||||||||||||
| 79 | 0 | $self->SUPER::init( @args ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | ▶ | sub serialize { | ||||||||||||||||||||||||||
|
Subroutine
serialize: called CC=25 SCAR=53.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 2 | my ($self, $name, $value, $opt) = @_; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 2 | ▶ | $opt->{ indent } ||= q{}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{"indent"} ||= ""
MC/DC0%0/1
$opt->{"indent"} ||= ""
$opt->{"indent"}
Truth table50%1/2
A
A= $opt->{"indent"}
| |||||||||||||||||||||||||||||
| 86 | 2 | ▶ | $opt->{ attributes } ||= []; | ||||||||||||||||||||||||||
|
Condition50%1/2
$opt->{"attributes"} ||= []
MC/DC0%0/1
$opt->{"attributes"} ||= []
$opt->{"attributes"}
Truth table50%1/2
A
A= $opt->{"attributes"}
| |||||||||||||||||||||||||||||
| 87 | 2 | my $variety = $self->get_variety(); | |||||||||||||||||||||||||||
| 88 | 2 | ▶ | my $xml = ($opt->{ readable }) ? $opt->{ indent } : q{}; # add indentation | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 2 | ▶ | if ( $opt->{ qualify } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | $opt->{ attributes } = [ ' xmlns="' . $self->get_targetNamespace .'"' ]; | |||||||||||||||||||||||||||
| 92 | 0 | delete $opt->{ qualify }; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | $xml .= join q{ } , "<$name" , @{ $opt->{ attributes } }; | |||||||||||||||||||||||||||
| 96 | 2 | delete $opt->{ attributes }; # don't propagate... | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 2 | ▶ | if ( $opt->{ autotype }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 1 | my $ns = $self->get_targetNamespace(); | |||||||||||||||||||||||||||
| 100 | # reverse namespace by prefix hash | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # build a list of hash keys (eg '#default', 'tns') whose values match our namespace (eg 'urn:myNamespace') | ||||||||||||||||||||||||||||
| 103 | 0 | (my @possible_namespace_names) = grep { $opt->{ namespace }->{$_} eq $ns } keys %{ $opt->{ namespace } }; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # put any '#default' option last | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | @possible_namespace_names = sort { $a eq '#default' ? 1 : $b eq '#default' ? -1 : $a cmp $b } @possible_namespace_names; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | if( grep( $_ ne '#default', @possible_namespace_names ) > 1 or ! @possible_namespace_names ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
grep(($_ ne "#default"), @possible_namespace_names) > 1 or not @possible_namespace_names
MC/DC0%0/2
grep(($_ ne "#default"), @possible_namespace_names) > 1 or not @possible_namespace_names
grep(($_ ne "#default"), @possible_namespace_names) > 1
not @possible_namespace_names
Truth table33%1/3
A or not(B)
A= grep(($_ ne "#default"), @possible_namespace_names) > 1B= not @possible_namespace_names
| |||||||||||||||||||||||||||||
| 109 | 1 | die "No prefix found for namespace $ns, or too many possible names: ``@possible_namespace_names''; there should be just one and maybe a '#default' entry"; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | 0 | my $prefix = $possible_namespace_names[0]; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | $xml .= join q{}, " type=\"$prefix:", $self->get_name(), '" ' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | if ($self->get_name() ); | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | 1 | $xml .= '>'; | |||||||||||||||||||||||||||
| 117 | 1 | ▶ | $xml .= "\n" if ( $opt->{ readable } ); # add linebreak | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 1 | ▶ | if ($self->schema) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ($self->schema()->get_elementFormDefault() ne "qualified") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | push @{$opt->{ attributes } }, q{xmlns=""} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | if ($self->get_targetNamespace() ne ""); | ||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | 1 | ▶ | if ( ($variety eq "sequence") or ($variety eq "all") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$variety eq "sequence" or $variety eq "all"
MC/DC0%0/2
$variety eq "sequence" or $variety eq "all"
$variety eq "sequence"
$variety eq "all"
Truth table33%1/3
A or B
A= $variety eq "sequence"B= $variety eq "all"
| |||||||||||||||||||||||||||||
| 126 | 0 | $opt->{ indent } .= "\t"; | |||||||||||||||||||||||||||
| 127 | 0 | for my $element (@{ $self->get_element() }) { | |||||||||||||||||||||||||||
| 128 | # resolve element ref | ||||||||||||||||||||||||||||
| 129 | # | ||||||||||||||||||||||||||||
| 130 | # Basic algorithm is like this: | ||||||||||||||||||||||||||||
| 131 | # If on serialization, we meet a element whose get_ref method | ||||||||||||||||||||||||||||
| 132 | # returns a true value, lookup the element from the <types> | ||||||||||||||||||||||||||||
| 133 | # definitions instead, and serialize this element. | ||||||||||||||||||||||||||||
| 134 | # | ||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if (my $ref = $element->get_ref()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | $element = $opt->{ typelib }->find_element( | ||||||||||||||||||||||||||||
| 137 | 0 | $element->expand($ref) | |||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # might be list - listify | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $value = [ $value ] if not ref $value eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | for my $single_value (@{ $value }) { | |||||||||||||||||||||||||||
| 145 | 0 | my $element_value; | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | if (blessed $single_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | my $method = 'get_' . $element->get_name(); | |||||||||||||||||||||||||||
| 148 | 0 | $element_value = $single_value->$method(); | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||
| 151 | 0 | $element_value = $single_value->{ $element->get_name() }; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $element_value = [ $element_value ] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | if not ref $element_value eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | $xml .= join q{} | ||||||||||||||||||||||||||||
| 157 | 0 | , map { $element->serialize( undef, $_, $opt ) } | |||||||||||||||||||||||||||
| 158 | 0 | @{ $element_value }; | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | 0 | $opt->{ indent } =~s/\t$//; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 1 | die "sorry, we just handle all and sequence types yet..."; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $xml .= $opt->{ indent } if ( $opt->{ readable } ); # add indentation | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 167 | 0 | $xml .= '</' . $name . '>'; | |||||||||||||||||||||||||||
| 168 | 0 | ▶ | $xml .= "\n" if ($opt->{ readable } ); # add linebreak | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | return $xml; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 1 | 1; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||