VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use