VirtualBox

source: vbox/trunk/src/VBox/Main/webservice/websrv-shared.inc.xsl@ 22379

Last change on this file since 22379 was 21819, checked in by vboxsync, 15 years ago

API/webservice: eliminate the last traces of special UUID data type handling.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette