genio-parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac644eef17af35c873fadfc31d21afc929de5f44
4
+ data.tar.gz: d406ac99c1b334f7667c8212e1b1c89455476127
5
+ SHA512:
6
+ metadata.gz: dbfc0c7d2377c9c35bbf42ceb8ee9b8a55f0768e4250636f7bf49b6737a7ea085467267af07e892b0fbf755afb3c6e5291fe536c98da20e3fd421b21b1a3e0c7
7
+ data.tar.gz: 299ffa89a942dde48bb4d94c29bbe4a7556b4b562d64fe0f153fab0b161dd0d89a9eeeff4cf5b12b252fa5301393f1f8ffa0c5073c31510aa47cf7663c9eab53
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 siddick
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Genio Parser
2
+
3
+ Supported formats are:
4
+
5
+ * json-schema
6
+ * wsdl
7
+ * wadl
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'genio-parser'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install genio-parser
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ schema = Genio::Parser::Format::JsonSchema.new
27
+ schema.load("path/to/schema.json")
28
+
29
+ schema.endpoint # String
30
+ schema.data_types # Hash( String => DataType )
31
+ schema.services # Hash( String => Service )
32
+ ```
33
+
34
+ ## Object members
35
+
36
+ DataType:
37
+
38
+ * extends
39
+ * properties
40
+
41
+ Property:
42
+
43
+ * type
44
+ * array
45
+ * enum
46
+
47
+ Service:
48
+
49
+ * operations
50
+
51
+ Operation:
52
+
53
+ * type
54
+ * path
55
+ * parameters
56
+ * request
57
+ * response
@@ -0,0 +1,180 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet version="1.0"
3
+ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
+ xmlns:wadl="http://wadl.dev.java.net/2009/02" exclude-result-prefixes="wadl xs">
5
+ <xsl:template match="wadl:application">
6
+ <packages>
7
+ <xsl:apply-templates
8
+ select="//*[local-name()='schema' and namespace-uri()='http://www.w3.org/2001/XMLSchema']" />
9
+ </packages>
10
+ <xsl:apply-templates select="wadl:resources" />
11
+ </xsl:template>
12
+
13
+ <xsl:template match="*[local-name()='element']">
14
+ <element name="{@name | ../@name}" type="@type" package="../@targetNamespace"></element>
15
+ </xsl:template>
16
+
17
+ <xsl:template match="wadl:resources">
18
+ <resources base="{@base}">
19
+ <xsl:apply-templates select="//wadl:resource" />
20
+ </resources>
21
+ </xsl:template>
22
+
23
+ <xsl:template match="wadl:resource">
24
+ <xsl:variable name="path">
25
+ <xsl:for-each select="ancestor-or-self::wadl:resource">
26
+ <xsl:value-of select="@path" />
27
+ </xsl:for-each>
28
+ </xsl:variable>
29
+
30
+ <resource path="{$path}">
31
+ <xsl:copy-of select="wadl:doc" />
32
+ <!-- TODO: Inherit matrix and template params from parent resources -->
33
+ <xsl:copy-of select="wadl:param" />
34
+ <xsl:copy-of select="wadl:method" />
35
+ </resource>
36
+ </xsl:template>
37
+
38
+ <!-- matching schema tag -->
39
+ <xsl:template match="//*[local-name()='schema']">
40
+ <!-- for namespaces -->
41
+ <package tns="{@targetNamespace}">
42
+ <namespaces>
43
+ <xsl:for-each select="namespace::*">
44
+ <namespace name="{name()}">
45
+ <xsl:value-of select='.' />
46
+ </namespace>
47
+ </xsl:for-each>
48
+ </namespaces>
49
+ <!-- for classes(requests and responses) -->
50
+ <elements>
51
+ <xsl:apply-templates select="./*[local-name()='element']" />
52
+ </elements>
53
+ <classes>
54
+ <xsl:apply-templates
55
+ select=".//*[local-name()='complexType' and not(starts-with(@name, 'ArrayOf_'))]" />
56
+ </classes>
57
+ </package>
58
+ </xsl:template>
59
+ <!-- matching simpletype tag(enum and simple values) -->
60
+ <xsl:template match="*[local-name()='simpleType']">
61
+ <xsl:choose>
62
+ <!-- for enums -->
63
+ <xsl:when
64
+ test=".//*[local-name()='restriction'] and .//*[local-name()='enumeration'] ">
65
+ <enum name="{@name}" package="{@type | ../@targetNamespace}">
66
+ <documentation>
67
+ <xsl:value-of select=".//*[local-name()='documentation']" />
68
+ </documentation>
69
+ <xsl:for-each select=".//*[local-name()='enumeration']">
70
+ <value>
71
+ <xsl:value-of select='@value' />
72
+ </value>
73
+ </xsl:for-each>
74
+ </enum>
75
+ </xsl:when>
76
+ <!-- for simple values -->
77
+ <xsl:otherwise>
78
+ <xsl:variable name="base"
79
+ select=".//*[local-name()='restriction']/@base" />
80
+ <element name="{@name}" package="{$base}"
81
+ type="{substring-after($base,':')}" />
82
+ </xsl:otherwise>
83
+ </xsl:choose>
84
+ </xsl:template>
85
+
86
+ <!-- matching element tag -->
87
+ <xsl:template match="*[local-name()='element']">
88
+ <element name="{@name | ../@name}" type="{@type}" package="{../@targetNamespace}"/>
89
+ </xsl:template>
90
+
91
+ <!-- matching complextype tag -->
92
+ <xsl:template match="*[local-name()='complexType']">
93
+ <class name="{@name | ../@name}" package="{@type | ../@targetNamespace}">
94
+ <!-- for annotation tag -->
95
+ <xsl:if test=".//*[local-name()='annotation'] ">
96
+ <documentation>
97
+ <xsl:value-of select="./*[local-name()='annotation']" />
98
+ </documentation>
99
+ </xsl:if>
100
+ <!-- for simpleContent tag with extension -->
101
+ <xsl:if
102
+ test="./*[local-name()='simpleContent'] and .//*[local-name()='extension']">
103
+ <properties>
104
+
105
+ <xsl:variable name="attrib" select=".//*[local-name()='attribute']" />
106
+ <xsl:choose>
107
+ <xsl:when test="substring-before($attrib/@type,':')='xs'">
108
+ <property name="{$attrib/@name}" type="{substring-after($attrib/@type,':')}"
109
+ min="1" simpletype="1" attrib="1" />
110
+ </xsl:when>
111
+ <xsl:otherwise>
112
+ <property name="{$attrib/@name}" type="{$attrib/@type}"
113
+ min="1" simpletype="0" package="{substring-before($attrib/@type,':')}"
114
+ attrib="1" />
115
+ </xsl:otherwise>
116
+ </xsl:choose>
117
+ <!-- with base -->
118
+ <xsl:variable name="base"
119
+ select=".//*[local-name()='extension']/@base" />
120
+ <property name="value" type="{substring-after($base,':')}"
121
+ min="1" simpletype="1" value="1" />
122
+ </properties>
123
+ </xsl:if>
124
+ <!-- tag with extension -->
125
+ <xsl:if test=".//*[local-name()='extension']">
126
+ <xsl:if
127
+ test="substring-before(.//*[local-name()='extension']/@base,':')!='xs'">
128
+ <extends
129
+ name="{substring-after(.//*[local-name()='extension']/@base,':')}"
130
+ package="{substring-before(.//*[local-name()='extension']/@base,':')}" />
131
+
132
+ </xsl:if>
133
+ </xsl:if>
134
+ <!-- for element tag -->
135
+ <xsl:if test=".//*[local-name()='element']">
136
+ <properties>
137
+ <xsl:for-each select=".//*[local-name()='element']">
138
+ <xsl:variable name="doc"
139
+ select=".//*[local-name()='documentation']" />
140
+ <xsl:choose>
141
+ <xsl:when test="substring-before(@type,':')='xs'">
142
+ <property name="{@name}" type="{substring-after(@type,':')}"
143
+ min="{@minOccurs}" max="{@maxOccurs}" documentation="{$doc}"
144
+ simpletype="1" />
145
+ </xsl:when>
146
+ <xsl:when
147
+ test="//*[local-name()='complexType' and @name=substring-after(current()/@type,':')] //*[@ref='soapenc:arrayType']">
148
+ <xsl:variable name="type"
149
+ select="//*[local-name()='complexType' and @name=substring-after(current()/@type,':')] //*[@ref='soapenc:arrayType']/@*[local-name()='wsdl:arrayType']" />
150
+ <property name="{@name}" type="{$type}"
151
+ package="{substring-before($type,':')}" min="{@minOccurs}" max="{@maxOccurs}"
152
+ documentation="{$doc}" simpletype="0" />
153
+ </xsl:when>
154
+ <!-- tag contains ref not type -->
155
+ <xsl:when test="not(@type) and @ref">
156
+ <xsl:choose>
157
+ <xsl:when test="@name">
158
+ <property name="{@name}" package="{substring-before(@ref,':')}"
159
+ min="{@minOccurs}" max="{@maxOccurs}" documentation="{$doc}"
160
+ simpletype="0" />
161
+ </xsl:when>
162
+ <xsl:otherwise>
163
+ <property name="{substring-after(@ref, ':')}" min="{@minOccurs}"
164
+ max="{@maxOccurs}" documentation="{$doc}"
165
+ package="{substring-before(@ref,':')}" simpletype="0" ref="{@ref}"/>
166
+ </xsl:otherwise>
167
+ </xsl:choose>
168
+ </xsl:when>
169
+ <xsl:otherwise>
170
+ <property name="{@name}" type="{substring-after(@type, ':')}"
171
+ simpletype="0" min="{@minOccurs}" max="{@maxOccurs}"
172
+ package="{substring-before(@type,':')}" documentation="{$doc}" />
173
+ </xsl:otherwise>
174
+ </xsl:choose>
175
+ </xsl:for-each>
176
+ </properties>
177
+ </xsl:if>
178
+ </class>
179
+ </xsl:template>
180
+ </xsl:stylesheet>
@@ -0,0 +1,371 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+
3
+ <xsl:stylesheet version="1.0"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
+ <!-- root elements -->
6
+ <xsl:template match="/">
7
+ <wsdl2ruby>
8
+ <properties>
9
+ <xsl:apply-templates select="//*[local-name()='definitions']" />
10
+ </properties>
11
+ <elements>
12
+ <xsl:apply-templates select=".//*[local-name()='element']" />
13
+ <xsl:apply-templates select=".//*[local-name()='simpleType'] " />
14
+ </elements>
15
+ <packages>
16
+ <xsl:apply-templates
17
+ select="//*[local-name()='schema' and namespace-uri()='http://www.w3.org/2001/XMLSchema']" />
18
+ </packages>
19
+
20
+ <services>
21
+ <xsl:apply-templates
22
+ select="//*[local-name()='service' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']" />
23
+ </services>
24
+ </wsdl2ruby>
25
+ </xsl:template>
26
+
27
+ <!-- matching schema tag -->
28
+ <xsl:template match="//*[local-name()='schema']">
29
+ <!-- for namespaces -->
30
+ <package tns="{@targetNamespace}">
31
+ <namespaces>
32
+ <xsl:for-each select="namespace::*">
33
+ <namespace name="{name()}">
34
+ <xsl:value-of select='.' />
35
+ </namespace>
36
+ </xsl:for-each>
37
+ </namespaces>
38
+ <!-- for classes(requests and responses) -->
39
+ <classes>
40
+ <xsl:apply-templates
41
+ select=".//*[local-name()='complexType' and not(starts-with(@name, 'ArrayOf_'))]" />
42
+ </classes>
43
+ </package>
44
+ </xsl:template>
45
+
46
+
47
+ <!-- matching definitions tag -->
48
+ <xsl:template match="*[local-name()='definitions']">
49
+ <xsl:for-each select="namespace::*">
50
+ <namespace name="{name()}">
51
+ <xsl:value-of select='.' />
52
+ </namespace>
53
+ </xsl:for-each>
54
+ <xsl:for-each select="attribute::*">
55
+ <attribute name="{name()}">
56
+ <xsl:value-of select='.' />
57
+ </attribute>
58
+ </xsl:for-each>
59
+ <xsl:for-each select="//*[local-name()='schema']">
60
+ <xsl:choose>
61
+ <xsl:when test="@elementFormDefault">
62
+ <elementFormDefault namespace="{@targetNamespace}"><xsl:value-of select="@elementFormDefault" /></elementFormDefault>
63
+ </xsl:when>
64
+ <xsl:when test="@attributeFormDefault">
65
+ <attributeFormDefault namespace="{@targetNamespace}"><xsl:value-of select="@attributeFormDefault" /></attributeFormDefault>
66
+ </xsl:when>
67
+ </xsl:choose>
68
+ </xsl:for-each>
69
+ </xsl:template>
70
+
71
+ <!-- matching simpletype tag(enum and simple values) -->
72
+ <xsl:template match="*[local-name()='simpleType']">
73
+ <xsl:if test="local-name(parent::node())!='union'">
74
+ <xsl:choose>
75
+ <!-- for enums -->
76
+ <xsl:when
77
+ test="./*[local-name()='restriction'] and .//*[local-name()='enumeration'] ">
78
+ <enum name="{@name | ../@name}" package="{@type | ancestor::*[local-name()='schema']/@targetNamespace}">
79
+ <documentation>
80
+ <xsl:value-of select=".//*[local-name()='documentation']" />
81
+ </documentation>
82
+ <xsl:for-each select=".//*[local-name()='enumeration']">
83
+ <value>
84
+ <xsl:value-of select='@value' />
85
+ </value>
86
+ </xsl:for-each>
87
+ </enum>
88
+ </xsl:when>
89
+ <!-- for simple values -->
90
+ <xsl:when
91
+ test="./*[local-name()='union']">
92
+ <element name="{@name}" package="xs:string" type="string" />
93
+ </xsl:when>
94
+ <xsl:otherwise>
95
+ <xsl:variable name="base"
96
+ select=".//*[local-name()='restriction']/@base" />
97
+ <element name="{@name}" package="{$base}"
98
+ type="{substring-after($base,':')}" />
99
+ </xsl:otherwise>
100
+ </xsl:choose>
101
+ </xsl:if>
102
+ </xsl:template>
103
+
104
+ <!-- matching element tag -->
105
+ <xsl:template match="*[local-name()='element']">
106
+ <xsl:choose>
107
+ <xsl:when test="@name">
108
+ <element name="{@name | ../@name}" package="{@type | ../@targetNamespace}"
109
+ type="{substring-after(@type,':')}"></element>
110
+ </xsl:when>
111
+ </xsl:choose>
112
+ </xsl:template>
113
+
114
+ <!-- matching complextype tag -->
115
+ <xsl:template match="*[local-name()='complexType']">
116
+ <class name="{@name | ../@name}" package="{ancestor::*[local-name()='schema']/@targetNamespace}">
117
+ <!-- for annotation tag -->
118
+ <xsl:if test=".//*[local-name()='annotation'] ">
119
+ <documentation>
120
+ <xsl:value-of select=".//*[local-name()='annotation']" />
121
+ </documentation>
122
+ </xsl:if>
123
+ <!-- for simpleContent tag with extension -->
124
+ <properties>
125
+ <xsl:if
126
+ test="./*[local-name()='simpleContent'] and .//*[local-name()='extension']">
127
+ <xsl:variable name="attrib" select=".//*[local-name()='attribute']" />
128
+ <xsl:choose>
129
+ <xsl:when test="substring-before($attrib/@type,':')='xs'">
130
+ <property name="{$attrib/@name}" type="{substring-after($attrib/@type,':')}"
131
+ min="1" simpletype="1" attrib="1" />
132
+ </xsl:when>
133
+ <xsl:otherwise>
134
+ <property name="{$attrib/@name}" type="{substring-after($attrib/@type,':')}"
135
+ min="1" simpletype="0" package="{substring-before($attrib/@type,':')}"
136
+ attrib="1" />
137
+ </xsl:otherwise>
138
+ </xsl:choose>
139
+ <!-- with base -->
140
+ <xsl:if test="substring-before(.//*[local-name()='extension']/@base, ':')='xs'">
141
+ <xsl:variable name="base" select=".//*[local-name()='extension']/@base" />
142
+ <property name="value" type="{substring-after($base,':')}" min="1" simpletype="1" value="1" />
143
+ </xsl:if>
144
+
145
+ </xsl:if>
146
+ <!-- tag with extension -->
147
+ <xsl:if test=".//*[local-name()='extension']">
148
+ <xsl:if test="substring-before(.//*[local-name()='extension']/@base,':')!='xs'">
149
+ <xsl:choose>
150
+ <xsl:when test="contains(.//*[local-name()='extension']/@base, ':')" >
151
+ <extends name="{substring-after(.//*[local-name()='extension']/@base,':')}"
152
+ package="{substring-before(.//*[local-name()='extension']/@base,':')}" />
153
+ </xsl:when>
154
+ <xsl:otherwise>
155
+ <xsl:variable name="package">
156
+ <xsl:variable name="defaultns" select="ancestor::*[local-name()='schema']/@targetNamespace" />
157
+ <xsl:for-each select="ancestor::*[local-name()='schema']/namespace::*">
158
+ <xsl:choose>
159
+ <xsl:when test="current() = $defaultns">
160
+ <xsl:value-of select="name()" />
161
+ </xsl:when>
162
+ </xsl:choose>
163
+ </xsl:for-each>
164
+ </xsl:variable>
165
+ <extends name="{.//*[local-name()='extension']/@base}" package="{$package}" />
166
+ </xsl:otherwise>
167
+ </xsl:choose>
168
+ </xsl:if>
169
+ </xsl:if>
170
+ <!-- for element tag -->
171
+ <xsl:if test=".//*[local-name()='element']">
172
+ <xsl:for-each select="./*[local-name()='sequence' or local-name()='all' or local-name()='choice']/*[local-name()='element']">
173
+ <xsl:variable name="doc"
174
+ select=".//*[local-name()='documentation']" />
175
+ <xsl:choose>
176
+ <xsl:when test="substring-before(@type,':')='xs'">
177
+ <property name="{@name}" type="{substring-after(@type,':')}"
178
+ min="{@minOccurs}" max="{@maxOccurs}" documentation="{$doc}"
179
+ simpletype="1" />
180
+ </xsl:when>
181
+ <xsl:when test="@type">
182
+ <property name="{@name}" type="{substring-after(@type, ':')}"
183
+ simpletype="0" min="{@minOccurs}" max="{@maxOccurs}"
184
+ package="{substring-before(@type, ':')}" documentation="{$doc}" />
185
+ </xsl:when>
186
+ <xsl:otherwise>
187
+ <xsl:choose>
188
+ <xsl:when test="@ref">
189
+ <xsl:variable name="refname">
190
+ <xsl:choose>
191
+ <xsl:when test="contains(@ref, ':')">
192
+ <xsl:value-of select="substring-after(@ref,':')" />
193
+ </xsl:when>
194
+ <xsl:otherwise>
195
+ <xsl:value-of select="@ref" />
196
+ </xsl:otherwise>
197
+ </xsl:choose>
198
+ </xsl:variable>
199
+ <xsl:variable name="reftype">
200
+ <xsl:for-each select="ancestor::*[local-name()='schema']/*[local-name()='element' and @name=$refname]">
201
+ <xsl:value-of select="@type" />
202
+ </xsl:for-each>
203
+ </xsl:variable>
204
+ <property name="{substring-after(@ref,':')}" type="{substring-after($reftype,':')}" min="{@minOccurs}"
205
+ max="{@maxOccurs}" documentation="{$doc}"
206
+ package="{substring-before(@ref, ':')}" simpletype="0" />
207
+ </xsl:when>
208
+ <xsl:otherwise>
209
+ <property name="{@name}" type="{@name}" simpletype="0" min="{@minOccurs}" max="{@maxOccurs}"
210
+ package="{substring-before(@type, ':')}" documentation="{$doc}" />
211
+ </xsl:otherwise>
212
+ </xsl:choose>
213
+ </xsl:otherwise>
214
+ </xsl:choose>
215
+ </xsl:for-each>
216
+ <xsl:for-each select="./*[local-name()='complexContent']/*[local-name()='extension']/*[local-name()='sequence' or local-name()='all' or local-name()='choice']/*[local-name()='element']">
217
+ <xsl:variable name="doc"
218
+ select=".//*[local-name()='documentation']" />
219
+ <xsl:choose>
220
+ <xsl:when test="substring-before(@type,':')='xs'">
221
+ <property name="{@name}" type="{substring-after(@type,':')}"
222
+ min="{@minOccurs}" max="{@maxOccurs}" documentation="{$doc}"
223
+ simpletype="1" />
224
+ </xsl:when>
225
+ <xsl:when test="@type">
226
+ <property name="{@name}" type="{substring-after(@type, ':')}"
227
+ simpletype="0" min="{@minOccurs}" max="{@maxOccurs}"
228
+ package="{substring-before(@type, ':')}" documentation="{$doc}" />
229
+ </xsl:when>
230
+ <xsl:otherwise>
231
+ <xsl:choose>
232
+ <xsl:when test="@ref">
233
+ <xsl:choose>
234
+ <xsl:when test="@name">
235
+ <property name="{@name}" package="{substring-before(@ref,':')}"
236
+ min="{@minOccurs}" max="{@maxOccurs}" documentation="{$doc}"
237
+ simpletype="0" />
238
+ </xsl:when>
239
+ <xsl:otherwise>
240
+ <property name="{substring-after(@ref,':')}" min="{@minOccurs}"
241
+ max="{@maxOccurs}" documentation="{$doc}"
242
+ package="{substring-before(@ref, ':')}" simpletype="0" />
243
+ </xsl:otherwise>
244
+ </xsl:choose>
245
+ </xsl:when>
246
+ <xsl:otherwise>
247
+ <property name="{@name}" type="{@name}" simpletype="0" min="{@minOccurs}" max="{@maxOccurs}"
248
+ package="{substring-before(@type, ':')}" documentation="{$doc}" />
249
+ </xsl:otherwise>
250
+ </xsl:choose>
251
+ </xsl:otherwise>
252
+ </xsl:choose>
253
+ </xsl:for-each>
254
+ </xsl:if>
255
+ <xsl:for-each select=".//*[local-name()='attribute']">
256
+ <xsl:variable name="attrib" select="." />
257
+ <xsl:choose>
258
+ <xsl:when test="substring-before($attrib/@type,':')='xs'">
259
+ <property name="{$attrib/@name}" type="{substring-after($attrib/@type,':')}"
260
+ min="1" simpletype="1" attrib="1" />
261
+ </xsl:when>
262
+ <xsl:otherwise>
263
+ <property name="{$attrib/@name}" type="{substring-after($attrib/@type,':')}"
264
+ min="1" simpletype="0" package="{substring-before($attrib/@type,':')}"
265
+ attrib="1" />
266
+ </xsl:otherwise>
267
+ </xsl:choose>
268
+ </xsl:for-each>
269
+
270
+ </properties>
271
+ </class>
272
+ </xsl:template>
273
+
274
+ <!-- matching service tag -->
275
+ <xsl:template match="*[local-name()='service']">
276
+ <service name="{@name}">
277
+ <xsl:apply-templates
278
+ select="*[local-name()='port' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']" />
279
+ </service>
280
+ </xsl:template>
281
+
282
+ <!-- matching port tag -->
283
+ <xsl:template match="*[local-name()='port']">
284
+ <xsl:apply-templates
285
+ select="//*[local-name()='binding' and @name=substring-after(current()/@binding,':')]" />
286
+ </xsl:template>
287
+
288
+
289
+ <!-- matching binding tag -->
290
+ <xsl:template match="*[local-name()='binding'] ">
291
+ <xsl:variable name="binding" select="concat(substring-before(@type, ':'), ':', @name)" />
292
+ <binding name="{@name}" type="{substring-before(@type, ':')}" />
293
+ <xsl:apply-templates
294
+ select="//*[local-name()='portType' and @name=substring-after(current()/@type, ':')]">
295
+ <xsl:with-param name="bindingname" select="//*[local-name()='port' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/' and @binding=$binding]/attribute::name" />
296
+ </xsl:apply-templates>
297
+ </xsl:template>
298
+
299
+ <!-- matching portType tag -->
300
+ <xsl:template match="*[local-name()='portType']">
301
+ <xsl:param name="bindingname" />
302
+ <functions>
303
+ <xsl:apply-templates select=".//*[local-name()='operation']">
304
+ <xsl:with-param name="bindingname" select="$bindingname" />
305
+ </xsl:apply-templates>
306
+ </functions>
307
+ </xsl:template>
308
+
309
+ <!-- matching operation tag -->
310
+ <xsl:template
311
+ match="*[local-name()='operation' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']">
312
+ <xsl:param name="bindingname" />
313
+ <xsl:variable name="operationname" select="@name" />
314
+ <function name="{@name}" soapAction="{//*[local-name()='binding' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']/*[local-name()='operation' and @name=$operationname]/*[local-name()='operation']/@soapAction}">
315
+ <documentation>
316
+ <xsl:value-of select="current()" />
317
+ </documentation>
318
+
319
+ <portname><xsl:value-of select="$bindingname" /></portname>
320
+ <!-- for requests -->
321
+ <parameters>
322
+ <xsl:apply-templates
323
+ select="//*[local-name()='message' and @name=substring-after(current()/*[local-name()='input']/@message, ':')]" />
324
+ <xsl:apply-templates select="//*[local-name()='binding' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/']/*[local-name()='operation' and namespace-uri()='http://schemas.xmlsoap.org/wsdl/' and @name=$operationname]/*[local-name()='input']/*[local-name()='header']/@message"/>
325
+ </parameters>
326
+ <!-- for responses -->
327
+ <returns>
328
+ <xsl:apply-templates
329
+ select="//*[local-name()='message' and @name=substring-after(current()/*[local-name()='output']/@message, ':')]" />
330
+ </returns>
331
+ <!-- for faults -->
332
+ <throws>
333
+ <xsl:apply-templates
334
+ select="//*[local-name()='message' and @name=substring-after(current()/*[local-name()='fault']/@message, ':')]" />
335
+ </throws>
336
+ </function>
337
+ </xsl:template>
338
+
339
+ <xsl:template match="@*[local-name()='message']">
340
+ <xsl:variable name="name" select="substring-after(current(), ':')" />
341
+ <variable name="{$name}" type="{//*[local-name()='element' and @name=$name]/@type}" package="{substring-before(current(), ':')}" part="header"/>
342
+ </xsl:template>
343
+
344
+ <!-- matching message tag -->
345
+ <xsl:template match="*[local-name()='message']">
346
+ <xsl:for-each select="*[local-name()='part']">
347
+ <xsl:choose>
348
+ <xsl:when test="substring-before(@type,':')='xsd'">
349
+ <variable name="{@name}" type="{substring-after(@type,':')}"
350
+ package="{substring-before(@type,':')}" part="body" />
351
+ </xsl:when>
352
+ <xsl:when
353
+ test="//*[local-name()='complexType' and @name=substring-after(current()/@type,':')]//*[@ref='soapenc:arrayType']">
354
+ <xsl:variable name="type"
355
+ select="//*[local-name()='complexType' and @name=substring-after(current()/@type,':')]//*[@ref='soapenc:arrayType']/@*[local-name()='arrayType']" />
356
+ <variable name="{@name}" type="{substring-after($type,':')}"
357
+ package="{substring-before(@type,':')}" part="body" />
358
+ </xsl:when>
359
+ <xsl:when test="not(@type) and @element">
360
+ <variable name="{substring-after(@element,':')}" type="{substring-after(@element,':')}"
361
+ package="{substring-before(@element,':')}" part="body" />
362
+ </xsl:when>
363
+ <xsl:otherwise>
364
+ <variable name="{@name}" type="{@type}"
365
+ package="{substring-before(@type,':')}" part="body" />
366
+ </xsl:otherwise>
367
+ </xsl:choose>
368
+ </xsl:for-each>
369
+ </xsl:template>
370
+
371
+ </xsl:stylesheet>