1 | <!--
|
---|
2 | websrv-shared.inc.xsl:
|
---|
3 | this gets included from the other websrv-*.xsl XSLT stylesheets
|
---|
4 | so we can share some definitions that must be the same for
|
---|
5 | all of them (like method prefixes/suffices).
|
---|
6 | See webservice/Makefile.kmk for an overview of all the things
|
---|
7 | generated for the webservice.
|
---|
8 |
|
---|
9 | Copyright (C) 2006-2010 Sun Microsystems, Inc.
|
---|
10 |
|
---|
11 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | available from http://www.virtualbox.org. This file is free software;
|
---|
13 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | General Public License (GPL) as published by the Free Software
|
---|
15 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 |
|
---|
19 | Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | additional information or have any questions.
|
---|
22 | -->
|
---|
23 |
|
---|
24 |
|
---|
25 | <xsl:stylesheet
|
---|
26 | version="1.0"
|
---|
27 | targetNamespace="http://schemas.xmlsoap.org/wsdl/"
|
---|
28 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
29 | xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
---|
30 | xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
---|
31 | xmlns:vbox="http://www.virtualbox.org/">
|
---|
32 |
|
---|
33 | <xsl:variable name="G_xsltIncludeFilename" select="'websrv-shared.inc.xsl'" />
|
---|
34 |
|
---|
35 | <!-- target namespace; this must match the xmlns:vbox in stylesheet opening tags! -->
|
---|
36 | <xsl:variable name="G_targetNamespace"
|
---|
37 | select='"http://www.virtualbox.org/"' />
|
---|
38 | <xsl:variable name="G_targetNamespaceSeparator"
|
---|
39 | select='""' />
|
---|
40 |
|
---|
41 | <!-- ENCODING SCHEME
|
---|
42 |
|
---|
43 | See: http://www-128.ibm.com/developerworks/webservices/library/ws-whichwsdl/
|
---|
44 |
|
---|
45 | Essentially "document" style means that each SOAP message is a complete and
|
---|
46 | self-explanatory document that does not rely on outside information for
|
---|
47 | validation.
|
---|
48 |
|
---|
49 | By contrast, the (older) "RPC" style allows for much shorter SOAP messages
|
---|
50 | that do not contain validation info like all types that are used, but then
|
---|
51 | again, caller and receiver must have agreed on a valid format in some other way.
|
---|
52 | With RPC, WSDL typically looks like this:
|
---|
53 |
|
---|
54 | <message name="myMethodRequest">
|
---|
55 | <part name="x" type="xsd:int"/>
|
---|
56 | <part name="y" type="xsd:float"/>
|
---|
57 | </message>
|
---|
58 |
|
---|
59 | This is why today "document" style is preferred. However, with document style,
|
---|
60 | one _cannot_ use "type" in <part> elements. Instead, one must use "element"
|
---|
61 | attributes that refer to <element> items in the type section. Like this:
|
---|
62 |
|
---|
63 | <types>
|
---|
64 | <schema>
|
---|
65 | <element name="xElement" type="xsd:int"/>
|
---|
66 | <element name="yElement" type="xsd:float"/>
|
---|
67 | </schema>
|
---|
68 | </types>
|
---|
69 |
|
---|
70 | <message name="myMethodRequest">
|
---|
71 | <part name="x" element="xElement"/>
|
---|
72 | <part name="y" element="yElement"/>
|
---|
73 | </message>
|
---|
74 |
|
---|
75 | The "encoded" and "literal" sub-styles then only determine whether the
|
---|
76 | individual types in the soap messages carry additional information in
|
---|
77 | attributes. "Encoded" was only used with RPC styles, really, and even that
|
---|
78 | is not widely supported any more.
|
---|
79 |
|
---|
80 | -->
|
---|
81 | <!-- These are the settings: all the other XSLTs react on this and are supposed
|
---|
82 | to be able to generate both valid RPC and document-style code. The only
|
---|
83 | allowed values are 'rpc' or 'document'. -->
|
---|
84 | <xsl:variable name="G_basefmt"
|
---|
85 | select='"document"' />
|
---|
86 | <xsl:variable name="G_parmfmt"
|
---|
87 | select='"literal"' />
|
---|
88 | <!-- <xsl:variable name="G_basefmt"
|
---|
89 | select='"rpc"' />
|
---|
90 | <xsl:variable name="G_parmfmt"
|
---|
91 | select='"encoded"' /> -->
|
---|
92 |
|
---|
93 | <!-- with document style, this is how we name the request and return element structures -->
|
---|
94 | <xsl:variable name="G_requestElementVarName"
|
---|
95 | select='"req"' />
|
---|
96 | <xsl:variable name="G_responseElementVarName"
|
---|
97 | select='"resp"' />
|
---|
98 | <!-- this is how we name the result parameter in messages -->
|
---|
99 | <xsl:variable name="G_result"
|
---|
100 | select='"returnval"' />
|
---|
101 |
|
---|
102 | <!-- we represent interface attributes by creating "get" and "set" methods; these
|
---|
103 | are the prefixes we use for that -->
|
---|
104 | <xsl:variable name="G_attributeGetPrefix"
|
---|
105 | select='"get"' />
|
---|
106 | <xsl:variable name="G_attributeSetPrefix"
|
---|
107 | select='"set"' />
|
---|
108 | <!-- separator between class name and method/attribute name; would be "::" in C++
|
---|
109 | but i'm unsure whether WSDL appreciates that (WSDL only) -->
|
---|
110 | <xsl:variable name="G_classSeparator"
|
---|
111 | select='"_"' />
|
---|
112 | <!-- for each interface method, we need to create both a "request" and a "response"
|
---|
113 | message; these are the suffixes we append to the method names for that -->
|
---|
114 | <xsl:variable name="G_methodRequest"
|
---|
115 | select='"RequestMsg"' />
|
---|
116 | <xsl:variable name="G_methodResponse"
|
---|
117 | select='"ResultMsg"' />
|
---|
118 | <!-- suffix for element declarations that describe request message parameters (WSDL only) -->
|
---|
119 | <xsl:variable name="G_requestMessageElementSuffix"
|
---|
120 | select='""' />
|
---|
121 | <!-- suffix for element declarations that describe request message parameters (WSDL only) -->
|
---|
122 | <xsl:variable name="G_responseMessageElementSuffix"
|
---|
123 | select='"Response"' />
|
---|
124 | <!-- suffix for portType names (WSDL only) -->
|
---|
125 | <xsl:variable name="G_portTypeSuffix"
|
---|
126 | select='"PortType"' />
|
---|
127 | <!-- suffix for binding names (WSDL only) -->
|
---|
128 | <xsl:variable name="G_bindingSuffix"
|
---|
129 | select='"Binding"' />
|
---|
130 | <!-- schema type to use for object references; while it is theoretically
|
---|
131 | possible to use a self-defined type (e.g. some vboxObjRef type that's
|
---|
132 | really an int), gSOAP gets a bit nasty and creates complicated structs
|
---|
133 | for function parameters when these types are used as output parameters.
|
---|
134 | So we just use "int" even though it's not as lucid.
|
---|
135 | One setting is for the WSDL emitter, one for the C++ emitter -->
|
---|
136 | <!--
|
---|
137 | <xsl:variable name="G_typeObjectRef"
|
---|
138 | select='"xsd:unsignedLong"' />
|
---|
139 | <xsl:variable name="G_typeObjectRef_gsoapH"
|
---|
140 | select='"ULONG64"' />
|
---|
141 | <xsl:variable name="G_typeObjectRef_CPP"
|
---|
142 | select='"WSDLT_ID"' />
|
---|
143 | -->
|
---|
144 | <xsl:variable name="G_typeObjectRef"
|
---|
145 | select='"xsd:string"' />
|
---|
146 | <xsl:variable name="G_typeObjectRef_gsoapH"
|
---|
147 | select='"std::string"' />
|
---|
148 | <xsl:variable name="G_typeObjectRef_CPP"
|
---|
149 | select='"std::string"' />
|
---|
150 | <!-- and what to call first the object parameter -->
|
---|
151 | <xsl:variable name="G_nameObjectRef"
|
---|
152 | select='"_this"' />
|
---|
153 | <!-- gSOAP encodes underscores with USCORE so this is used in our C++ code -->
|
---|
154 | <xsl:variable name="G_nameObjectRefEncoded"
|
---|
155 | select='"_USCOREthis"' />
|
---|
156 |
|
---|
157 | <!-- type to represent enums with in C++ COM callers -->
|
---|
158 | <xsl:variable name="G_funcPrefixInputEnumConverter"
|
---|
159 | select='"EnumSoap2Com_"' />
|
---|
160 | <xsl:variable name="G_funcPrefixOutputEnumConverter"
|
---|
161 | select='"EnumCom2Soap_"' />
|
---|
162 |
|
---|
163 | <xsl:variable name="G_aSharedTypes">
|
---|
164 | <type idlname="octet" xmlname="unsignedByte" cname="unsigned char" gluename="BYTE" javaname="Short" />
|
---|
165 | <type idlname="boolean" xmlname="boolean" cname="bool" gluename="BOOL" javaname="Boolean" />
|
---|
166 | <type idlname="short" xmlname="short" cname="short" gluename="SHORT" javaname="Short" />
|
---|
167 | <type idlname="unsigned short" xmlname="unsignedShort" cname="unsigned short" gluename="USHORT" javaname="Integer" />
|
---|
168 | <type idlname="long" xmlname="int" cname="int" gluename="LONG" javaname="Integer" />
|
---|
169 | <type idlname="unsigned long" xmlname="unsignedInt" cname="unsigned int" gluename="ULONG" javaname="Long" />
|
---|
170 | <type idlname="long long" xmlname="long" cname="LONG64" gluename="LONG64" javaname="Long" />
|
---|
171 | <type idlname="unsigned long long" xmlname="unsignedLong" cname="ULONG64" gluename="ULONG64" javaname="BigInteger" />
|
---|
172 | <type idlname="double" xmlname="double" cname="double" gluename="" javaname="Double" />
|
---|
173 | <type idlname="float" xmlname="float" cname="float" gluename="" javaname="Float" />
|
---|
174 | <type idlname="wstring" xmlname="string" cname="std::string" gluename="" javaname="String" />
|
---|
175 | <type idlname="uuid" xmlname="string" cname="std::string" gluename="" javaname="String" />
|
---|
176 | <type idlname="result" xmlname="unsignedInt" cname="unsigned int" gluename="HRESULT" javaname="Long" />
|
---|
177 | </xsl:variable>
|
---|
178 |
|
---|
179 | <!--
|
---|
180 | warning:
|
---|
181 | -->
|
---|
182 |
|
---|
183 | <xsl:template name="warning">
|
---|
184 | <xsl:param name="msg" />
|
---|
185 |
|
---|
186 | <xsl:message terminate="no">
|
---|
187 | <xsl:value-of select="concat('[', $G_xsltFilename, '] Warning in ', $msg)" />
|
---|
188 | </xsl:message>
|
---|
189 | </xsl:template>
|
---|
190 |
|
---|
191 | <!--
|
---|
192 | fatalError:
|
---|
193 | -->
|
---|
194 |
|
---|
195 | <xsl:template name="fatalError">
|
---|
196 | <xsl:param name="msg" />
|
---|
197 |
|
---|
198 | <xsl:message terminate="yes">
|
---|
199 | <xsl:value-of select="concat('[', $G_xsltFilename, '] Error in ', $msg)" />
|
---|
200 | </xsl:message>
|
---|
201 | </xsl:template>
|
---|
202 |
|
---|
203 | <!--
|
---|
204 | debugMsg
|
---|
205 | -->
|
---|
206 |
|
---|
207 | <xsl:template name="debugMsg">
|
---|
208 | <xsl:param name="msg" />
|
---|
209 |
|
---|
210 | <xsl:if test="$G_argDebug">
|
---|
211 | <xsl:message terminate="no">
|
---|
212 | <xsl:value-of select="concat('[', $G_xsltFilename, '] ', $msg)" />
|
---|
213 | </xsl:message>
|
---|
214 | </xsl:if>
|
---|
215 | </xsl:template>
|
---|
216 |
|
---|
217 | <!--
|
---|
218 | uncapitalize
|
---|
219 | -->
|
---|
220 |
|
---|
221 | <xsl:template name="uncapitalize">
|
---|
222 | <xsl:param name="str" select="."/>
|
---|
223 | <xsl:value-of select="
|
---|
224 | concat(
|
---|
225 | translate(substring($str,1,1),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),
|
---|
226 | substring($str,2)
|
---|
227 | )
|
---|
228 | "/>
|
---|
229 | </xsl:template>
|
---|
230 | <!--
|
---|
231 | uncapitalize in the way JAX-WS understands, see #2910
|
---|
232 | -->
|
---|
233 |
|
---|
234 | <xsl:template name="uncapitalize2">
|
---|
235 | <xsl:param name="str" select="."/>
|
---|
236 | <xsl:variable name="strlen">
|
---|
237 | <xsl:value-of select="string-length($str)"/>
|
---|
238 | </xsl:variable>
|
---|
239 | <xsl:choose>
|
---|
240 | <xsl:when test="$strlen>1">
|
---|
241 | <xsl:choose>
|
---|
242 | <xsl:when test="contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ',substring($str,1,1))
|
---|
243 | and
|
---|
244 | contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ',substring($str,2,1))">
|
---|
245 | <xsl:variable name="cdr">
|
---|
246 | <xsl:call-template name="uncapitalize2">
|
---|
247 | <xsl:with-param name="str" select="substring($str,2)"/>
|
---|
248 | </xsl:call-template>
|
---|
249 | </xsl:variable>
|
---|
250 | <xsl:value-of select="
|
---|
251 | concat(
|
---|
252 | translate(substring($str,1,1),
|
---|
253 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
---|
254 | 'abcdefghijklmnopqrstuvwxyz'),
|
---|
255 | $cdr
|
---|
256 | )
|
---|
257 | "/>
|
---|
258 | </xsl:when>
|
---|
259 | <xsl:otherwise>
|
---|
260 | <!--<xsl:value-of select="concat(substring($str,1,1),$cdr)"/>-->
|
---|
261 | <xsl:value-of select="$str"/>
|
---|
262 | </xsl:otherwise>
|
---|
263 | </xsl:choose>
|
---|
264 | </xsl:when>
|
---|
265 | <xsl:when test="$strlen=1">
|
---|
266 | <xsl:value-of select="
|
---|
267 | translate($str,
|
---|
268 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
---|
269 | 'abcdefghijklmnopqrstuvwxyz')
|
---|
270 | "/>
|
---|
271 | </xsl:when>
|
---|
272 | <xsl:otherwise>
|
---|
273 | </xsl:otherwise>
|
---|
274 | </xsl:choose>
|
---|
275 | </xsl:template>
|
---|
276 | <!--
|
---|
277 | capitalize
|
---|
278 | -->
|
---|
279 |
|
---|
280 | <xsl:template name="capitalize">
|
---|
281 | <xsl:param name="str" select="."/>
|
---|
282 | <xsl:value-of select="
|
---|
283 | concat(
|
---|
284 | translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
|
---|
285 | substring($str,2)
|
---|
286 | )
|
---|
287 | "/>
|
---|
288 | </xsl:template>
|
---|
289 |
|
---|
290 | <!--
|
---|
291 | makeGetterName:
|
---|
292 | -->
|
---|
293 | <xsl:template name="makeGetterName">
|
---|
294 | <xsl:param name="attrname" />
|
---|
295 | <xsl:variable name="capsname"><xsl:call-template name="capitalize"><xsl:with-param name="str" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
296 | <xsl:value-of select="concat($G_attributeGetPrefix, $capsname)" />
|
---|
297 | </xsl:template>
|
---|
298 |
|
---|
299 | <!--
|
---|
300 | makeSetterName:
|
---|
301 | -->
|
---|
302 | <xsl:template name="makeSetterName">
|
---|
303 | <xsl:param name="attrname" />
|
---|
304 | <xsl:variable name="capsname"><xsl:call-template name="capitalize"><xsl:with-param name="str" select="$attrname" /></xsl:call-template></xsl:variable>
|
---|
305 | <xsl:value-of select="concat($G_attributeSetPrefix, $capsname)" />
|
---|
306 | </xsl:template>
|
---|
307 |
|
---|
308 | <!--
|
---|
309 | makeJaxwsMethod: compose idevInterfaceMethod out of IDEVInterface::method
|
---|
310 | -->
|
---|
311 | <xsl:template name="makeJaxwsMethod">
|
---|
312 | <xsl:param name="ifname" />
|
---|
313 | <xsl:param name="methodname" />
|
---|
314 | <xsl:variable name="uncapsif"><xsl:call-template name="uncapitalize2"><xsl:with-param name="str" select="$ifname" /></xsl:call-template></xsl:variable>
|
---|
315 | <xsl:variable name="capsmethod"><xsl:call-template name="capitalize"><xsl:with-param name="str" select="$methodname" /></xsl:call-template></xsl:variable>
|
---|
316 | <xsl:value-of select="concat($uncapsif, $capsmethod)" />
|
---|
317 | </xsl:template>
|
---|
318 |
|
---|
319 |
|
---|
320 | <!--
|
---|
321 | makeJaxwsMethod2: compose iInterfaceMethod out of IInterface::method
|
---|
322 | -->
|
---|
323 | <xsl:template name="makeJaxwsMethod2">
|
---|
324 | <xsl:param name="ifname" />
|
---|
325 | <xsl:param name="methodname" />
|
---|
326 | <xsl:variable name="uncapsif"><xsl:call-template name="uncapitalize"><xsl:with-param name="str" select="$ifname" /></xsl:call-template></xsl:variable>
|
---|
327 | <xsl:variable name="capsmethod"><xsl:call-template name="capitalize"><xsl:with-param name="str" select="$methodname" /></xsl:call-template></xsl:variable>
|
---|
328 | <xsl:value-of select="concat($uncapsif, $capsmethod)" />
|
---|
329 | </xsl:template>
|
---|
330 |
|
---|
331 | <!--
|
---|
332 | emitNewline:
|
---|
333 | -->
|
---|
334 | <xsl:template name="emitNewline">
|
---|
335 | <xsl:text>
|
---|
336 | </xsl:text>
|
---|
337 | </xsl:template>
|
---|
338 |
|
---|
339 | <!--
|
---|
340 | emitNewlineIndent8:
|
---|
341 | -->
|
---|
342 | <xsl:template name="emitNewlineIndent8">
|
---|
343 | <xsl:text>
|
---|
344 | </xsl:text>
|
---|
345 | </xsl:template>
|
---|
346 |
|
---|
347 | <!--
|
---|
348 | escapeUnderscores
|
---|
349 | -->
|
---|
350 | <xsl:template name="escapeUnderscores">
|
---|
351 | <xsl:param name="string" />
|
---|
352 | <xsl:if test="contains($string, '_')">
|
---|
353 | <xsl:value-of select="substring-before($string, '_')" />_USCORE<xsl:call-template name="escapeUnderscores"><xsl:with-param name="string"><xsl:value-of select="substring-after($string, '_')" /></xsl:with-param></xsl:call-template>
|
---|
354 | </xsl:if>
|
---|
355 | <xsl:if test="not(contains($string, '_'))"><xsl:value-of select="$string" />
|
---|
356 | </xsl:if>
|
---|
357 | </xsl:template>
|
---|
358 |
|
---|
359 | </xsl:stylesheet>
|
---|