VirtualBox

source: vbox/trunk/src/VBox/Main/webservice/websrv-wsdl2gsoapH.xsl@ 20042

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

fixed webservice copyright

  • Property svn:eol-style set to native
File size: 12.5 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 websrv-gsoapH.xsl:
5 XSLT stylesheet that generates vboxweb_gsoapH.h from
6 VirtualBox.xidl.Such "header" files can be fed into
7 gSOAP's soapcpp2 to create web service client headers
8 and server stubs. (The reason for this appears to be
9 that gSOAP predates WSDL and thus needed some format
10 to describe the syntax of a web service. gSOAP these
11 days comes with wsdl2h, which converts a WSDL file
12 to gSOAP's "header" format, but that has license
13 problems and so we generate the gSOAP "header" via
14 XSLT.)
15
16 Copyright (C) 2006-2007 Sun Microsystems, Inc.
17
18 This file is part of VirtualBox Open Source Edition (OSE), as
19 available from http://www.virtualbox.org. This file is free software;
20 you can redistribute it and/or modify it under the terms of the GNU
21 General Public License (GPL) as published by the Free Software
22 Foundation, in version 2 as it comes in the "COPYING" file of the
23 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
24 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
25
26 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 Clara, CA 95054 USA or visit http://www.sun.com if you need
28 additional information or have any questions.
29-->
30
31<xsl:stylesheet
32 version="1.0"
33 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
34 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
35 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
36 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
37 xmlns:vbox="http://www.virtualbox.org/"
38 xmlns:exsl="http://exslt.org/common"
39 extension-element-prefixes="exsl"
40 >
41
42 <xsl:param name="G_argDebug" />
43
44 <xsl:output method="text"/>
45
46 <xsl:strip-space elements="*"/>
47
48<!-- - - - - - - - - - - - - - - - - - - - - - -
49 global XSLT variables
50 - - - - - - - - - - - - - - - - - - - - - - -->
51
52<xsl:variable name="G_xsltFilename" select="'websrv-wsdl2gsoapH.xsl'" />
53
54<xsl:include href="websrv-shared.inc.xsl" />
55
56<!-- collect all interfaces with "wsmap='suppress'" in a global variable for
57 quick lookup -->
58<xsl:variable name="G_setSuppressedInterfaces"
59 select="//interface[@wsmap='suppress']" />
60
61
62<!-- - - - - - - - - - - - - - - - - - - - - - -
63 root match
64 - - - - - - - - - - - - - - - - - - - - - - -->
65
66<xsl:template match="/wsdl:definitions">
67 <xsl:text><![CDATA[
68/* DO NOT EDIT! This is a generated file.
69 * Generated from: vboxweb.wsdl (generated WSDL file)
70 * Generator: src/VBox/Main/webservice/websrv-gsoapH.xsl
71 *
72 * Note: This is not a real C/C++ header file. Instead, gSOAP uses files like this
73 * one -- with a pseudo-C-header syntax -- to describe a web service API.
74 */
75
76// STL vector containers
77#import "stlvector.h"
78
79]]></xsl:text>
80
81 <xsl:value-of select="concat('//gsoap vbox schema namespace: ', $G_targetNamespace)" />
82 <xsl:value-of select="concat('//gsoap vbox schema form: unqualified', '')" />
83
84 <xsl:text>
85/****************************************************************************
86 *
87 * declarations
88 *
89 ****************************************************************************/
90
91// forward declarations
92 class _vbox__InvalidObjectFault;
93class _vbox__RuntimeFault;
94
95struct SOAP_ENV__Detail
96{
97 _vbox__InvalidObjectFault *vbox__InvalidObjectFault;
98 _vbox__RuntimeFault *vbox__RuntimeFault;
99 int __type;
100 void *fault;
101 _XML __any;
102};</xsl:text>
103 <xsl:call-template name="emitNewline" />
104
105 <xsl:apply-templates />
106</xsl:template>
107
108<xsl:template name="convertSequence">
109 <xsl:param name="xmltype" />
110 <xsl:param name="ctype" />
111
112 <xsl:value-of select="concat('class ', $ctype)" />
113 <xsl:call-template name="emitNewline" />
114 <xsl:text>{</xsl:text>
115 <xsl:call-template name="emitNewline" />
116 <xsl:text> public:</xsl:text>
117 <xsl:call-template name="emitNewline" />
118 <xsl:for-each select="xsd:element">
119 <xsl:variable name="typefield" select="@type" />
120 <xsl:variable name="xmltypefield" select="substring($typefield, 5)" /><!-- remove "xsd:" prefix-->
121 <xsl:variable name="withoutvboxtypefield" select="substring($typefield, 6)" /><!-- remove "vbox:" prefix-->
122 <xsl:variable name="ctypefield" select="exsl:node-set($G_aSharedTypes)/type[@xmlname=$xmltypefield]/@cname" />
123 <xsl:text> </xsl:text>
124 <xsl:choose>
125 <xsl:when test="$ctypefield">
126 <!-- array or simple type: depends on whether maxOccurs="unbounded" is in WSDL -->
127 <xsl:choose>
128 <xsl:when test="@maxOccurs='unbounded'">
129 <xsl:value-of select="concat('std::vector&lt;', $ctypefield, '&gt;')" />
130 </xsl:when>
131 <xsl:otherwise>
132 <xsl:value-of select="$ctypefield" />
133 </xsl:otherwise>
134 </xsl:choose>
135 </xsl:when>
136 <!-- is there an enum of this type? (look up in simple types) -->
137 <xsl:when test="//xsd:simpleType[@name=$withoutvboxtypefield]">
138 <xsl:variable name="enumname">
139 <xsl:value-of select="concat('enum vbox__', $withoutvboxtypefield)" />
140 </xsl:variable>
141 <xsl:choose>
142 <xsl:when test="@maxOccurs='unbounded'">
143 <xsl:value-of select="concat('std::vector&lt;', $enumname, '&gt;')" />
144 </xsl:when>
145 <xsl:otherwise>
146 <xsl:value-of select="$enumname" />
147 </xsl:otherwise>
148 </xsl:choose>
149 </xsl:when>
150 <!-- is this one of the vbox types? (look up in complex types) -->
151 <xsl:when test="//xsd:complexType[@name=$withoutvboxtypefield]">
152 <!-- array or simple type: depends on whether maxOccurs="unbounded" is in WSDL -->
153 <xsl:choose>
154 <xsl:when test="@maxOccurs='unbounded'">
155 <xsl:value-of select="concat('std::vector&lt;vbox__', $withoutvboxtypefield, '*&gt;')" />
156 </xsl:when>
157 <xsl:otherwise>
158 <xsl:value-of select="concat('vbox__', $withoutvboxtypefield, '*')" />
159 </xsl:otherwise>
160 </xsl:choose>
161 </xsl:when>
162 <xsl:otherwise>
163 <xsl:value-of select="concat('std::string', '')" />
164 </xsl:otherwise>
165 </xsl:choose>
166 <xsl:variable name="underscoredname">
167 <xsl:call-template name="escapeUnderscores">
168 <xsl:with-param name="string" select="@name" />
169 </xsl:call-template>
170 </xsl:variable>
171 <xsl:value-of select="concat(' ', $underscoredname, ' 1;')" />
172 <xsl:call-template name="emitNewline" />
173 </xsl:for-each>
174 <xsl:text> struct soap *soap;</xsl:text>
175 <xsl:call-template name="emitNewline" />
176 <xsl:text>};</xsl:text>
177 <xsl:call-template name="emitNewline" />
178 <xsl:call-template name="emitNewline" />
179</xsl:template>
180
181<xsl:template match="wsdl:types/xsd:schema">
182
183 <!-- enums are represented as simple types -->
184 <xsl:for-each select="xsd:simpleType">
185 <xsl:variable name="ctype" select="concat('vbox__', @name)" />
186 <xsl:for-each select="xsd:restriction">
187 <xsl:value-of select="concat('enum ', $ctype)" />
188 <xsl:call-template name="emitNewline" />
189 <xsl:text>{</xsl:text>
190 <xsl:call-template name="emitNewline" />
191 <xsl:for-each select="xsd:enumeration">
192 <xsl:variable name="underscoredname">
193 <xsl:call-template name="escapeUnderscores">
194 <xsl:with-param name="string" select="@value" />
195 </xsl:call-template>
196 </xsl:variable>
197 <xsl:value-of select="concat(' ', $ctype, '__', $underscoredname)" />
198 <xsl:if test = "not(position()=last())" >
199 <xsl:text >,</xsl:text>
200 </xsl:if>
201 <xsl:call-template name="emitNewline" />
202 </xsl:for-each>
203 <xsl:text>};</xsl:text>
204 <xsl:call-template name="emitNewline" />
205 <xsl:call-template name="emitNewline" />
206 </xsl:for-each>
207 </xsl:for-each>
208
209 <!-- structs and arrays are represented as complex types -->
210 <xsl:for-each select="xsd:complexType">
211 <xsl:variable name="xmltype" select="@name" />
212 <xsl:variable name="ctype" select="concat('vbox__', $xmltype)" />
213 <xsl:for-each select="xsd:sequence">
214 <xsl:call-template name="convertSequence">
215 <xsl:with-param name="xmltype" select="$xmltype" />
216 <xsl:with-param name="ctype" select="$ctype" />
217 </xsl:call-template>
218 </xsl:for-each>
219 </xsl:for-each>
220
221 <!-- individual message elements are represented with xsd:element -> xsd:complexType -> xsdSequence -->
222 <xsl:for-each select="xsd:element">
223 <xsl:variable name="xmltype" select="@name" />
224 <xsl:variable name="underscoredname">
225 <xsl:call-template name="escapeUnderscores">
226 <xsl:with-param name="string" select="$xmltype" />
227 </xsl:call-template>
228 </xsl:variable>
229 <xsl:variable name="ctype" select="concat('_vbox__', $underscoredname)" />
230 <xsl:for-each select="xsd:complexType">
231 <xsl:for-each select="xsd:sequence">
232 <xsl:call-template name="convertSequence">
233 <xsl:with-param name="xmltype" select="$xmltype" />
234 <xsl:with-param name="ctype" select="$ctype" />
235 </xsl:call-template>
236 </xsl:for-each>
237 </xsl:for-each>
238 </xsl:for-each>
239</xsl:template>
240
241<xsl:template match="wsdl:portType">
242
243 <xsl:value-of select="concat('//gsoap vbox service name: vbox', $G_bindingSuffix)" />
244 <xsl:call-template name="emitNewline" />
245 <xsl:value-of select="concat('//gsoap vbox service type: vbox', $G_portTypeSuffix)" />
246 <xsl:call-template name="emitNewline" />
247 <xsl:value-of select="concat('//gsoap vbox service namespace: ', $G_targetNamespace, $G_targetNamespaceSeparator)" />
248 <xsl:call-template name="emitNewline" />
249 <xsl:value-of select="concat('//gsoap vbox service transport: ', 'http://schemas.xmlsoap.org/soap/http')" />
250 <xsl:call-template name="emitNewline" />
251
252 <xsl:for-each select="wsdl:operation">
253 <xsl:variable name="methodname" select="@name" />
254 <xsl:variable name="cmethodname">
255 <xsl:call-template name="escapeUnderscores">
256 <xsl:with-param name="string" select="$methodname" />
257 </xsl:call-template>
258 </xsl:variable>
259 <xsl:variable name="requestmsg" select="concat($methodname, $G_methodRequest)" />
260 <xsl:variable name="responsemsg" select="concat($methodname, $G_methodResponse)" />
261
262 <xsl:call-template name="emitNewline" />
263 <xsl:value-of select="concat('//gsoap vbox service method-style: ', $cmethodname, ' ', $G_basefmt)" />
264 <xsl:call-template name="emitNewline" />
265 <xsl:value-of select="concat('//gsoap vbox service method-encoding: ', $cmethodname, ' ', $G_parmfmt)" />
266 <xsl:call-template name="emitNewline" />
267 <xsl:value-of select="concat('//gsoap vbox service method-action: ', $cmethodname, ' &quot;&quot;')" />
268 <xsl:call-template name="emitNewline" />
269 <xsl:value-of select="concat('//gsoap vbox service method-fault: ', $cmethodname, ' vbox__InvalidObjectFault')" />
270 <xsl:call-template name="emitNewline" />
271 <xsl:value-of select="concat('//gsoap vbox service method-fault: ', $cmethodname, ' vbox__RuntimeFault')" />
272 <xsl:call-template name="emitNewline" />
273 <xsl:value-of select="concat('int __vbox__', $cmethodname, '(')" />
274 <xsl:call-template name="emitNewline" />
275
276 <!-- request element -->
277 <xsl:variable name="reqtype" select="//wsdl:message[@name=$requestmsg]/wsdl:part/@element" />
278 <xsl:if test="not($reqtype)">
279 <xsl:call-template name="fatalError">
280 <xsl:with-param name="msg" select="concat('wsdl:portType match: Cannot find message with &quot;name&quot;=&quot;', $requestmsg, '&quot;.')" />
281 </xsl:call-template>
282 </xsl:if>
283 <xsl:variable name="creqtype">
284 <xsl:call-template name="escapeUnderscores">
285 <xsl:with-param name="string" select="substring($reqtype, 6)" />
286 </xsl:call-template>
287 </xsl:variable>
288 <xsl:value-of select="concat(' _vbox__', $creqtype, '* vbox__', $creqtype, ',')"/>
289 <xsl:call-template name="emitNewline" />
290 <!-- response element -->
291 <xsl:variable name="resptype" select="//wsdl:message[@name=$responsemsg]/wsdl:part/@element" />
292 <xsl:if test="not($resptype)">
293 <xsl:call-template name="fatalError">
294 <xsl:with-param name="msg" select="concat('wsdl:portType match: Cannot find message with &quot;name&quot;=&quot;', $responsemsg, '&quot;.')" />
295 </xsl:call-template>
296 </xsl:if>
297 <xsl:variable name="cresptype">
298 <xsl:call-template name="escapeUnderscores">
299 <xsl:with-param name="string" select="substring($resptype, 6)" />
300 </xsl:call-template>
301 </xsl:variable>
302 <xsl:value-of select="concat(' _vbox__', $cresptype, '* vbox__', $cresptype)"/>
303 <xsl:call-template name="emitNewline" />
304
305 <xsl:text>);</xsl:text>
306 <xsl:call-template name="emitNewline" />
307
308 </xsl:for-each>
309</xsl:template>
310
311</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