VirtualBox

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

Last change on this file since 48279 was 45483, checked in by vboxsync, 12 years ago

Main/glue+idl+webservice: move the type mapping XSLT include file to a central place, it is not webservice specific, and extend it slightly

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