File Coverage

blib/lib/Pod/WSDL/Utils.pm
Criterion Covered Total %
statement 14 15 93.3
branch 7 8 87.5
condition 2 3 66.6
subroutine 3 3 100.0
pod 1 1 100.0
total 27 30 90.0


line stmt bran cond sub pod time code
1             package Pod::WSDL::Utils;
2              
3 11     11   73812 use strict;
  11         27  
  11         430  
4 11     11   80 use warnings;
  11         25  
  11         9557  
5             require Exporter;
6              
7             our @ISA = qw(Exporter);
8             our %EXPORT_TAGS = (
9             writexml => [qw($END_PREFIX_NAME $START_PREFIX_NAME $EMPTY_PREFIX_NAME)],
10             namespaces => [qw(%BASIC_NAMESPACES $DEFAULT_NS_DECL $TARGET_NS_DECL $IMPL_NS_DECL)],
11             messages => [qw($REQUEST_SUFFIX_NAME $RESPONSE_SUFFIX_NAME $RETURN_SUFFIX_NAME $EMPTY_MESSAGE_NAME $DOCUMENT_STYLE $RPC_STYLE $LITERAL_USE $ENCODED_USE $PART_IN $FAULT_NAME $MESSAGE_PART)],
12             types => [qw($ARRAY_PREFIX_NAME %XSD_STANDARD_TYPE_MAP)],
13             );
14              
15             our @EXPORT_OK = (@{$EXPORT_TAGS{writexml}}, @{$EXPORT_TAGS{namespaces}}, @{$EXPORT_TAGS{messages}}, @{$EXPORT_TAGS{types}});
16             our $VERSION = "0.05";
17              
18             # writexml
19             our $END_PREFIX_NAME = 'end';
20             our $START_PREFIX_NAME = 'start';
21             our $EMPTY_PREFIX_NAME = 'empty';
22              
23             # namespaces
24             our %BASIC_NAMESPACES = qw (
25             soapenc http://schemas.xmlsoap.org/soap/encoding/
26             wsdl http://schemas.xmlsoap.org/wsdl/
27             wsdlsoap http://schemas.xmlsoap.org/wsdl/soap/
28             xsd http://www.w3.org/2001/XMLSchema
29             );
30              
31             our $DEFAULT_NS_DECL = 'podwsdl';
32             our $TARGET_NS_DECL = 'tns1';
33             our $IMPL_NS_DECL = 'impl';
34              
35             # messages
36             our $REQUEST_SUFFIX_NAME = 'Request';
37             our $RESPONSE_SUFFIX_NAME = 'Response';
38             our $RETURN_SUFFIX_NAME = 'Return';
39             our $EMPTY_MESSAGE_NAME = 'empty';
40             our $FAULT_NAME = 'fault';
41             our $DOCUMENT_STYLE = 'document';
42             our $RPC_STYLE = 'rpc';
43             our $LITERAL_USE = 'literal';
44             our $ENCODED_USE = 'encoded';
45             our $PART_IN = 'PartIn';
46             our $MESSAGE_PART = 'MessagePart';
47              
48             # types
49             our $ARRAY_PREFIX_NAME = 'ArrayOf';
50             our %XSD_STANDARD_TYPE_MAP;
51              
52             # see http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/
53             $XSD_STANDARD_TYPE_MAP{$_} = 1 for qw(
54             anyType
55             anySimpleType
56              
57             string
58             normalizedString
59             token
60             anyURI
61             language
62             Name
63             QName
64             NCName
65              
66             boolean
67              
68             float
69             double
70              
71             decimal
72             int
73             positiveInteger
74             nonPositiveInteger
75             negativeInteger
76             nonNegativeInteger
77             long
78             short
79             byte
80             unsignedInt
81             unsignedLong
82             unsignedShort
83             unsignedByte
84              
85             duration
86             dateTime
87             time
88             date
89             gYearMonth
90             gYear
91             gMonthDay
92             gDay
93             gMonth
94              
95             hexBinary
96             base64Binary
97             );
98              
99             sub getTypeDescr {
100 4     4 1 518 my $typeName = shift;
101 4         9 my $array = shift;
102 4         6 my $ownType = shift;
103            
104 4 100 66     32 if ((defined $typeName) and (exists $XSD_STANDARD_TYPE_MAP{$typeName})) {
    50          
105 2 100       6 if ($array) {
106 1         11 return $TARGET_NS_DECL . ':' . $ARRAY_PREFIX_NAME . ucfirst $typeName;
107             } else {
108 1         11 return 'xsd:' . $typeName;
109             }
110             } elsif (defined $ownType) {
111 2 100       12 return $TARGET_NS_DECL . ':' . ($array ? $ARRAY_PREFIX_NAME . ucfirst $ownType->wsdlName : $ownType->wsdlName);
112             } else {
113 0           return undef;
114             }
115             }
116              
117             1;
118             __END__