VirtualBox

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

Last change on this file since 96308 was 96308, checked in by vboxsync, 22 months ago

src/VBox/Main: XML/XSL comment fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 11.6 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-2020 Oracle Corporation
14
15 This file is part of VirtualBox Open Source Edition (OSE), as
16 available from http://www.virtualbox.org. This file is free software;
17 you can redistribute it and/or modify it under the terms of the GNU
18 General Public License (GPL) as published by the Free Software
19 Foundation, in version 2 as it comes in the "COPYING" file of the
20 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
21 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
22-->
23
24<xsl:stylesheet
25 version="1.0"
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
28 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
29 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
30 xmlns:vbox="http://www.virtualbox.org/"
31 xmlns:exsl="http://exslt.org/common"
32 extension-element-prefixes="exsl"
33 >
34
35 <xsl:param name="G_argDebug" />
36
37 <xsl:output method="text"/>
38
39 <xsl:strip-space elements="*"/>
40
41<!-- - - - - - - - - - - - - - - - - - - - - - -
42 global XSLT variables
43 - - - - - - - - - - - - - - - - - - - - - - -->
44
45<xsl:variable name="G_xsltFilename" select="'websrv-wsdl2gsoapH.xsl'" />
46
47<xsl:include href="../idl/typemap-shared.inc.xsl" />
48
49<!-- collect all interfaces with "wsmap='suppress'" in a global variable for
50 quick lookup -->
51<xsl:variable name="G_setSuppressedInterfaces"
52 select="//interface[@wsmap='suppress']" />
53
54
55<!-- - - - - - - - - - - - - - - - - - - - - - -
56 Keys for more efficiently looking up of stuff
57 - - - - - - - - - - - - - - - - - - - - - - -->
58
59<xsl:key name="G_keyMessagesByName" match="//wsdl:message[@name]" use="@name"/>
60<xsl:key name="G_keySimpleTypesByName" match="//xsd:simpleType[@name]" use="@name"/>
61<xsl:key name="G_keyComplexTypesByName" match="//xsd:complexType[@name]" use="@name"/>
62
63
64<!-- - - - - - - - - - - - - - - - - - - - - - -
65 root match
66 - - - - - - - - - - - - - - - - - - - - - - -->
67
68<xsl:template match="/wsdl:definitions">
69 <xsl:text><![CDATA[
70/* DO NOT EDIT! This is a generated file.
71 * Generated from: vboxweb.wsdl (generated WSDL file)
72 * Generator: src/VBox/Main/webservice/websrv-gsoapH.xsl
73 *
74 * Note: This is not a real C/C++ header file. Instead, gSOAP uses files like this
75 * one -- with a pseudo-C-header syntax -- to describe a web service API.
76 */
77
78// STL vector containers
79#import "stlvector.h"
80
81]]></xsl:text>
82
83 <xsl:value-of select="concat('//gsoap vbox schema namespace: ', $G_targetNamespace)" />
84 <xsl:value-of select="concat('//gsoap vbox schema form: unqualified', '')" />
85
86 <xsl:text>
87/****************************************************************************
88 *
89 * declarations
90 *
91 ****************************************************************************/
92
93// forward declarations
94class _vbox__InvalidObjectFault;
95class _vbox__RuntimeFault;
96
97struct SOAP_ENV__Detail
98{
99 _vbox__InvalidObjectFault *vbox__InvalidObjectFault;
100 _vbox__RuntimeFault *vbox__RuntimeFault;
101 int __type;
102 void *fault;
103 _XML __any;
104};
105</xsl:text>
106
107 <xsl:apply-templates />
108</xsl:template>
109
110<xsl:template name="convertSequence">
111 <xsl:param name="xmltype" />
112 <xsl:param name="ctype" />
113
114 <xsl:value-of select="concat('class ', $ctype, $G_sNewLine)" />
115 <xsl:text>{
116 public:
117</xsl:text>
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="count(key('G_keySimpleTypesByName', $withoutvboxtypefield)) > 0">
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="count(key('G_keyComplexTypesByName', $withoutvboxtypefield)) > 0">
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;', $G_sNewLine)" />
172 </xsl:for-each>
173 <xsl:text> struct soap *soap;
174};
175</xsl:text>
176<xsl:call-template name="xsltprocNewlineOutputHack"/>
177
178</xsl:template>
179
180<xsl:template match="wsdl:types/xsd:schema">
181
182 <!-- enums are represented as simple types -->
183 <xsl:for-each select="xsd:simpleType">
184 <xsl:variable name="ctype" select="concat('vbox__', @name)" />
185 <xsl:for-each select="xsd:restriction">
186 <xsl:value-of select="concat('enum ', $ctype)" />
187 <xsl:text>
188{
189</xsl:text>
190 <xsl:for-each select="xsd:enumeration">
191 <xsl:variable name="underscoredname">
192 <xsl:call-template name="escapeUnderscores">
193 <xsl:with-param name="string" select="@value" />
194 </xsl:call-template>
195 </xsl:variable>
196 <xsl:value-of select="concat(' ', $ctype, '__', $underscoredname)" />
197 <xsl:if test = "not(position()=last())" >
198 <xsl:text >,</xsl:text>
199 </xsl:if>
200 <xsl:text>
201</xsl:text>
202 </xsl:for-each>
203 <xsl:text>};
204
205</xsl:text>
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, $G_sNewLine)" />
244 <xsl:value-of select="concat('//gsoap vbox service type: vbox', $G_portTypeSuffix, $G_sNewLine)" />
245 <xsl:value-of select="concat('//gsoap vbox service namespace: ', $G_targetNamespace, $G_targetNamespaceSeparator, $G_sNewLine)" />
246 <xsl:value-of select="concat('//gsoap vbox service transport: ', 'http://schemas.xmlsoap.org/soap/http', $G_sNewLine)" />
247
248 <xsl:for-each select="wsdl:operation">
249 <xsl:variable name="methodname" select="@name" />
250 <xsl:variable name="cmethodname">
251 <xsl:call-template name="escapeUnderscores">
252 <xsl:with-param name="string" select="$methodname" />
253 </xsl:call-template>
254 </xsl:variable>
255 <xsl:variable name="requestmsg" select="concat($methodname, $G_methodRequest)" />
256 <xsl:variable name="responsemsg" select="concat($methodname, $G_methodResponse)" />
257
258 <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-style: ', $cmethodname, ' ', $G_basefmt)" />
259 <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-encoding: ', $cmethodname, ' ', $G_parmfmt)" />
260 <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-action: ', $cmethodname, ' &quot;&quot;')" />
261 <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-fault: ', $cmethodname, ' vbox__InvalidObjectFault')" />
262 <xsl:value-of select="concat($G_sNewLine, '//gsoap vbox service method-fault: ', $cmethodname, ' vbox__RuntimeFault')" />
263 <xsl:value-of select="concat($G_sNewLine, 'int __vbox__', $cmethodname, '(', $G_sNewLine)" />
264
265 <!-- request element -->
266 <xsl:variable name="reqtype" select="key('G_keyMessagesByName', $requestmsg)/wsdl:part/@element" />
267 <xsl:if test="not($reqtype)">
268 <xsl:call-template name="fatalError">
269 <xsl:with-param name="msg" select="concat('wsdl:portType match: Cannot find message with &quot;name&quot;=&quot;', $requestmsg, '&quot;.')" />
270 </xsl:call-template>
271 </xsl:if>
272 <xsl:variable name="creqtype">
273 <xsl:call-template name="escapeUnderscores">
274 <xsl:with-param name="string" select="substring($reqtype, 6)" />
275 </xsl:call-template>
276 </xsl:variable>
277 <xsl:value-of select="concat(' _vbox__', $creqtype, '* vbox__', $creqtype, ',', $G_sNewLine)"/>
278 <!-- response element -->
279 <xsl:variable name="resptype" select="key('G_keyMessagesByName', $responsemsg)/wsdl:part/@element" />
280 <xsl:if test="not($resptype)">
281 <xsl:call-template name="fatalError">
282 <xsl:with-param name="msg" select="concat('wsdl:portType match: Cannot find message with &quot;name&quot;=&quot;', $responsemsg, '&quot;.')" />
283 </xsl:call-template>
284 </xsl:if>
285 <xsl:variable name="cresptype">
286 <xsl:call-template name="escapeUnderscores">
287 <xsl:with-param name="string" select="substring($resptype, 6)" />
288 </xsl:call-template>
289 </xsl:variable>
290 <xsl:value-of select="concat(' _vbox__', $cresptype, '* vbox__', $cresptype, $G_sNewLine)"/>
291
292 <xsl:text>);</xsl:text>
293 <xsl:call-template name="xsltprocNewlineOutputHack"/>
294
295 </xsl:for-each>
296</xsl:template>
297
298</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use