VirtualBox

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

Last change on this file since 42852 was 42667, checked in by vboxsync, 12 years ago

Main/webservice: report invalid object reference if a NULL object should be converted to a struct. This is a bit ambiguous, but right now we have no better option. Additionally a bit of dead code removal and stop mislabeling structs as enums.

  • Property svn:eol-style set to native
File size: 13.8 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 See webservice/Makefile.kmk for an overview of all the things
7 generated for the webservice.
8
9 Copyright (C) 2006-2010 Oracle Corporation
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
20
21<xsl:stylesheet
22 version="1.0"
23 targetNamespace="http://schemas.xmlsoap.org/wsdl/"
24 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
25 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
26 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
27 xmlns:vbox="http://www.virtualbox.org/">
28
29<xsl:variable name="G_xsltIncludeFilename" select="'websrv-shared.inc.xsl'" />
30
31<!-- target namespace; this must match the xmlns:vbox in stylesheet opening tags! -->
32<xsl:variable name="G_targetNamespace"
33 select='"http://www.virtualbox.org/"' />
34<xsl:variable name="G_targetNamespaceSeparator"
35 select='""' />
36
37<!-- ENCODING SCHEME
38
39 See: http://www-128.ibm.com/developerworks/webservices/library/ws-whichwsdl/
40
41 Essentially "document" style means that each SOAP message is a complete and
42 self-explanatory document that does not rely on outside information for
43 validation.
44
45 By contrast, the (older) "RPC" style allows for much shorter SOAP messages
46 that do not contain validation info like all types that are used, but then
47 again, caller and receiver must have agreed on a valid format in some other way.
48 With RPC, WSDL typically looks like this:
49
50 <message name="myMethodRequest">
51 <part name="x" type="xsd:int"/>
52 <part name="y" type="xsd:float"/>
53 </message>
54
55 This is why today "document" style is preferred. However, with document style,
56 one _cannot_ use "type" in <part> elements. Instead, one must use "element"
57 attributes that refer to <element> items in the type section. Like this:
58
59 <types>
60 <schema>
61 <element name="xElement" type="xsd:int"/>
62 <element name="yElement" type="xsd:float"/>
63 </schema>
64 </types>
65
66 <message name="myMethodRequest">
67 <part name="x" element="xElement"/>
68 <part name="y" element="yElement"/>
69 </message>
70
71 The "encoded" and "literal" sub-styles then only determine whether the
72 individual types in the soap messages carry additional information in
73 attributes. "Encoded" was only used with RPC styles, really, and even that
74 is not widely supported any more.
75
76-->
77<!-- These are the settings: all the other XSLTs react on this and are supposed
78 to be able to generate both valid RPC and document-style code. The only
79 allowed values are 'rpc' or 'document'. -->
80<xsl:variable name="G_basefmt"
81 select='"document"' />
82<xsl:variable name="G_parmfmt"
83 select='"literal"' />
84<!-- <xsl:variable name="G_basefmt"
85 select='"rpc"' />
86<xsl:variable name="G_parmfmt"
87 select='"encoded"' /> -->
88
89<!-- with document style, this is how we name the request and return element structures -->
90<xsl:variable name="G_requestElementVarName"
91 select='"req"' />
92<xsl:variable name="G_responseElementVarName"
93 select='"resp"' />
94<!-- this is how we name the result parameter in messages -->
95<xsl:variable name="G_result"
96 select='"returnval"' />
97
98<!-- we represent interface attributes by creating "get" and "set" methods; these
99 are the prefixes we use for that -->
100<xsl:variable name="G_attributeGetPrefix"
101 select='"get"' />
102<xsl:variable name="G_attributeSetPrefix"
103 select='"set"' />
104<!-- separator between class name and method/attribute name; would be "::" in C++
105 but i'm unsure whether WSDL appreciates that (WSDL only) -->
106<xsl:variable name="G_classSeparator"
107 select='"_"' />
108<!-- for each interface method, we need to create both a "request" and a "response"
109 message; these are the suffixes we append to the method names for that -->
110<xsl:variable name="G_methodRequest"
111 select='"RequestMsg"' />
112<xsl:variable name="G_methodResponse"
113 select='"ResultMsg"' />
114<!-- suffix for element declarations that describe request message parameters (WSDL only) -->
115<xsl:variable name="G_requestMessageElementSuffix"
116 select='""' />
117<!-- suffix for element declarations that describe request message parameters (WSDL only) -->
118<xsl:variable name="G_responseMessageElementSuffix"
119 select='"Response"' />
120<!-- suffix for portType names (WSDL only) -->
121<xsl:variable name="G_portTypeSuffix"
122 select='"PortType"' />
123<!-- suffix for binding names (WSDL only) -->
124<xsl:variable name="G_bindingSuffix"
125 select='"Binding"' />
126<!-- schema type to use for object references; while it is theoretically
127 possible to use a self-defined type (e.g. some vboxObjRef type that's
128 really an int), gSOAP gets a bit nasty and creates complicated structs
129 for function parameters when these types are used as output parameters.
130 So we just use "int" even though it's not as lucid.
131 One setting is for the WSDL emitter, one for the C++ emitter -->
132<!--
133<xsl:variable name="G_typeObjectRef"
134 select='"xsd:unsignedLong"' />
135<xsl:variable name="G_typeObjectRef_gsoapH"
136 select='"ULONG64"' />
137<xsl:variable name="G_typeObjectRef_CPP"
138 select='"WSDLT_ID"' />
139-->
140<xsl:variable name="G_typeObjectRef"
141 select='"xsd:string"' />
142<xsl:variable name="G_typeObjectRef_gsoapH"
143 select='"std::string"' />
144<xsl:variable name="G_typeObjectRef_CPP"
145 select='"std::string"' />
146<!-- and what to call first the object parameter -->
147<xsl:variable name="G_nameObjectRef"
148 select='"_this"' />
149<!-- gSOAP encodes underscores with USCORE so this is used in our C++ code -->
150<xsl:variable name="G_nameObjectRefEncoded"
151 select='"_USCOREthis"' />
152
153<!-- type to represent enums within C++ COM callers -->
154<xsl:variable name="G_funcPrefixInputEnumConverter"
155 select='"EnumSoap2Com_"' />
156<xsl:variable name="G_funcPrefixOutputEnumConverter"
157 select='"EnumCom2Soap_"' />
158
159<!-- type to represent structs within C++ COM callers -->
160<xsl:variable name="G_funcPrefixOutputStructConverter"
161 select='"StructCom2Soap_"' />
162
163<xsl:variable name="G_aSharedTypes">
164 <type idlname="octet" xmlname="unsignedByte" cname="unsigned char" gluename="BYTE" javaname="byte" />
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>
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