line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SOAP::WSDL::XSD::Element; |
2
|
2
|
|
|
2
|
|
11839
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
3
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
770
|
use Class::Std::Fast::Storable; |
|
2
|
|
|
|
|
30073
|
|
|
2
|
|
|
|
|
13
|
|
5
|
2
|
|
|
2
|
|
252
|
use base qw(SOAP::WSDL::Base); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
837
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = 3.003; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# id provided by Base |
10
|
|
|
|
|
|
|
# name provided by Base |
11
|
|
|
|
|
|
|
# annotation provided by Base |
12
|
|
|
|
|
|
|
my %simpleType_of :ATTR(:name :default<()>); |
13
|
|
|
|
|
|
|
my %complexType_of :ATTR(:name :default<()>); |
14
|
|
|
|
|
|
|
my %facet_of :ATTR(:name :default<()>); |
15
|
|
|
|
|
|
|
my %type_of :ATTR(:name :default<()>); |
16
|
|
|
|
|
|
|
my %abstract_of :ATTR(:name :default<()>); |
17
|
|
|
|
|
|
|
my %block_of :ATTR(:name :default<()>); |
18
|
|
|
|
|
|
|
my %default_of :ATTR(:name :default<()>); |
19
|
|
|
|
|
|
|
my %final_of :ATTR(:name :default<()>); |
20
|
|
|
|
|
|
|
my %fixed_of :ATTR(:name :default<()>); |
21
|
|
|
|
|
|
|
my %form_of :ATTR(:name |
22
|
|
|
|
|
|
|
my %maxOccurs_of :ATTR(:name :default<()>); |
23
|
|
|
|
|
|
|
my %minOccurs_of :ATTR(:name :default<()>); |
24
|
|
|
|
|
|
|
my %nillable_of :ATTR(:name :default<()>); |
25
|
|
|
|
|
|
|
my %ref_of :ATTR(:name[ :default<()>); ] |
26
|
|
|
|
|
|
|
my %substitutionGroup_of :ATTR(:name :default<()>); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub first_simpleType { |
29
|
11
|
|
|
11
|
0
|
383
|
my $result_ref = $simpleType_of{ ident shift }; |
30
|
11
|
100
|
|
|
|
42
|
return if not $result_ref; |
31
|
10
|
100
|
|
|
|
29
|
return $result_ref if (not ref $result_ref eq 'ARRAY'); |
32
|
7
|
|
|
|
|
16
|
return $result_ref->[0]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub first_complexType { |
36
|
3
|
|
|
3
|
0
|
7
|
my $result_ref = $complexType_of{ ident shift }; |
37
|
3
|
100
|
|
|
|
14
|
return if not $result_ref; |
38
|
2
|
100
|
|
|
|
7
|
return $result_ref if (not ref $result_ref eq 'ARRAY'); |
39
|
1
|
|
|
|
|
4
|
return $result_ref->[0]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# serialize type instead... |
43
|
|
|
|
|
|
|
sub serialize { |
44
|
9
|
|
|
9
|
0
|
2546
|
my ($self, $name, $value, $opt) = @_; |
45
|
9
|
|
|
|
|
8
|
my $type; |
46
|
9
|
|
|
|
|
11
|
my $typelib = $opt->{ typelib }; |
47
|
9
|
|
|
|
|
6
|
my %ns_map = %{ $opt->{ namespace } }; |
|
9
|
|
|
|
|
15
|
|
48
|
9
|
|
|
|
|
19
|
my $ident = ident $self; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# abstract elements may only be serialized via ref - and then we have a |
51
|
|
|
|
|
|
|
# name... |
52
|
9
|
100
|
100
|
|
|
51
|
die "cannot serialize abstract element" if $abstract_of{ $ident } |
53
|
|
|
|
|
|
|
and not $name; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# TODO: implement final and substitutionGroup - maybe never implement |
56
|
|
|
|
|
|
|
# substitutionGroup ? |
57
|
|
|
|
|
|
|
|
58
|
8
|
100
|
|
|
|
19
|
$name = $self->get_name() if not ($name); |
59
|
|
|
|
|
|
|
|
60
|
8
|
100
|
|
|
|
15
|
if ( $opt->{ qualify } ) { |
61
|
2
|
|
|
|
|
9
|
$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
|
100
|
|
|
|
19
|
if (not defined $value) { |
68
|
6
|
100
|
|
|
|
9
|
$value = $default_of{ ident $self } if $default_of{ ident $self }; |
69
|
|
|
|
|
|
|
} |
70
|
8
|
100
|
|
|
|
36
|
$value = $fixed_of{ ident $self } if $fixed_of{ ident $self }; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# TODO check nillable and serialize empty data correctly |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# return if minOccurs is 0 and we have no value |
75
|
8
|
50
|
33
|
|
|
33
|
if (defined $minOccurs_of{ ident $self } |
76
|
|
|
|
|
|
|
and $minOccurs_of{ ident $self } == 0) { |
77
|
0
|
0
|
|
|
|
0
|
return q{} if not defined $value; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# handle direct simpleType and complexType here |
81
|
8
|
50
|
|
|
|
31
|
if ($type = $self->first_simpleType() ) { # simpleType |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
82
|
8
|
|
|
|
|
22
|
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
|
0
|
|
|
|
|
die "no element for ref $prefix:$localname" if (not $type); |
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
|
0
|
|
|
|
|
die "no type for $prefix:$localname $ns_map{$prefix}" if (not $type); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return $type->serialize( $name, $value, $opt ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|