VirtualBox

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

Last change on this file since 16120 was 16120, checked in by vboxsync, 16 years ago

export webservices to OSE

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

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