VirtualBox

source: vbox/trunk/src/VBox/Main/xml/SchemaDefs.xsl@ 28851

Last change on this file since 28851 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 * A template to generate a header that will contain some important constraints
5 * extracted from the VirtualBox XML Schema (VirtualBox-settings-*.xsd).
6 * The output file name must be SchemaDefs.h.
7 *
8 * This template depends on XML Schema structure (type names and constraints)
9 * and should be reviewed on every Schema change.
10
11 Copyright (C) 2006-2008 Oracle Corporation
12
13 This file is part of VirtualBox Open Source Edition (OSE), as
14 available from http://www.virtualbox.org. This file is free software;
15 you can redistribute it and/or modify it under the terms of the GNU
16 General Public License (GPL) as published by the Free Software
17 Foundation, in version 2 as it comes in the "COPYING" file of the
18 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20-->
21
22<xsl:stylesheet version="1.0"
23 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
24 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
25>
26<xsl:output method="text"/>
27
28<xsl:strip-space elements="*"/>
29
30<xsl:param name="mode" expr=''/>
31
32<!--
33// helpers
34////////////////////////////////////////////////////////////////////////////////
35-->
36
37<!--
38 * Extract the specified value and assign it to an enum member with the given
39 * name
40-->
41<xsl:template name="defineEnumMember">
42 <xsl:param name="member"/>
43 <xsl:param name="select"/>
44 <xsl:if test="$select">
45 <xsl:value-of select="concat($member, ' = ', $select, ',&#x0A;')"/>
46 </xsl:if>
47</xsl:template>
48
49<!--
50// templates
51////////////////////////////////////////////////////////////////////////////////
52-->
53
54<!--
55 * shut down all implicit templates
56-->
57<xsl:template match="*"/>
58<xsl:template match="*" mode="declare"/>
59<xsl:template match="*" mode="declare.enum"/>
60<xsl:template match="*" mode="define"/>
61
62<xsl:template match="/">
63 <xsl:choose>
64 <xsl:when test="$mode='declare'">
65 <xsl:apply-templates select="/" mode="declare"/>
66 </xsl:when>
67 <xsl:when test="$mode='define'">
68 <xsl:apply-templates select="/" mode="define"/>
69 </xsl:when>
70 <xsl:otherwise>
71 <xsl:message terminate="yes">
72Value '<xsl:value-of select="$mode"/>' of parameter 'mode' is invalid!
73 </xsl:message>
74 </xsl:otherwise>
75 </xsl:choose>
76</xsl:template>
77
78<!--
79 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80 * declare mode (C++ header file)
81 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
82-->
83
84<xsl:template match="/" mode="declare">
85<xsl:text>
86/*
87 * DO NOT EDIT.
88 *
89 * This header is automatically generated from the VirtualBox XML Settings
90 * Schema and contains selected schema constraints declared in C++.
91 */
92
93#ifndef ____H_SCHEMADEFS
94#define ____H_SCHEMADEFS
95
96namespace SchemaDefs
97{
98 enum
99 {
100</xsl:text>
101
102 <xsl:apply-templates select="xsd:schema" mode="declare.enum"/>
103
104<xsl:text> };
105</xsl:text>
106
107<xsl:apply-templates select="xsd:schema" mode="declare"/>
108
109<xsl:text>}
110
111#endif // ____H_SCHEMADEFS
112</xsl:text>
113</xsl:template>
114
115<!--
116 * enumeration values
117-->
118<xsl:template match="xsd:schema" mode="declare.enum">
119
120 <!-- process include statements -->
121 <xsl:for-each select="xsd:include">
122 <!-- skip VirtualBox-settings-root.xsd inclusion as it is computed at runtime -->
123 <xsl:if test="not(@schemaLocation='VirtualBox-settings-root.xsd')">
124 <xsl:apply-templates select="document(@schemaLocation)/xsd:schema" mode="declare.enum"/>
125 </xsl:if>
126 </xsl:for-each>
127
128 <xsl:call-template name="defineEnumMember">
129 <xsl:with-param name="member" select="' MinGuestRAM'"/>
130 <xsl:with-param name="select" select="
131 xsd:complexType[@name='TMemory']/xsd:attribute[@name='RAMSize']//xsd:minInclusive/@value
132 "/>
133 </xsl:call-template>
134 <xsl:call-template name="defineEnumMember">
135 <xsl:with-param name="member" select="' MaxGuestRAM'"/>
136 <xsl:with-param name="select" select="
137 xsd:complexType[@name='TMemory']/xsd:attribute[@name='RAMSize']//xsd:maxInclusive/@value
138 "/>
139 </xsl:call-template>
140
141 <xsl:call-template name="defineEnumMember">
142 <xsl:with-param name="member" select="' MinGuestVRAM'"/>
143 <xsl:with-param name="select" select="
144 xsd:complexType[@name='TDisplay']/xsd:attribute[@name='VRAMSize']//xsd:minInclusive/@value
145 "/>
146 </xsl:call-template>
147 <xsl:call-template name="defineEnumMember">
148 <xsl:with-param name="member" select="' MaxGuestVRAM'"/>
149 <xsl:with-param name="select" select="
150 xsd:complexType[@name='TDisplay']/xsd:attribute[@name='VRAMSize']//xsd:maxInclusive/@value
151 "/>
152 </xsl:call-template>
153
154 <xsl:call-template name="defineEnumMember">
155 <xsl:with-param name="member" select="' MinCPUCount'"/>
156 <xsl:with-param name="select" select="
157 xsd:simpleType[@name='TCPUCount']//xsd:minInclusive/@value
158 "/>
159 </xsl:call-template>
160 <xsl:call-template name="defineEnumMember">
161 <xsl:with-param name="member" select="' MaxCPUCount'"/>
162 <xsl:with-param name="select" select="
163 xsd:simpleType[@name='TCPUCount']//xsd:maxInclusive/@value
164 "/>
165 </xsl:call-template>
166
167 <xsl:call-template name="defineEnumMember">
168 <xsl:with-param name="member" select="' MaxGuestMonitors'"/>
169 <xsl:with-param name="select" select="
170 xsd:complexType[@name='TDisplay']/xsd:attribute[@name='monitorCount']//xsd:maxInclusive/@value
171 "/>
172 </xsl:call-template>
173 <xsl:call-template name="defineEnumMember">
174 <xsl:with-param name="member" select="' NetworkAdapterCount'"/>
175 <xsl:with-param name="select" select="
176 xsd:complexType[@name='TNetworkAdapter']/xsd:attribute[@name='slot']//xsd:maxExclusive/@value
177 "/>
178 </xsl:call-template>
179
180 <xsl:call-template name="defineEnumMember">
181 <xsl:with-param name="member" select="' SerialPortCount'"/>
182 <xsl:with-param name="select" select="
183 xsd:complexType[@name='TUARTPort']/xsd:attribute[@name='slot']//xsd:maxExclusive/@value
184 "/>
185 </xsl:call-template>
186
187 <xsl:call-template name="defineEnumMember">
188 <xsl:with-param name="member" select="' ParallelPortCount'"/>
189 <xsl:with-param name="select" select="
190 xsd:complexType[@name='TLPTPort']/xsd:attribute[@name='slot']//xsd:maxExclusive/@value
191 "/>
192 </xsl:call-template>
193
194 <xsl:call-template name="defineEnumMember">
195 <xsl:with-param name="member" select="' MaxBootPosition'"/>
196 <xsl:with-param name="select" select="
197 xsd:complexType[@name='TBoot']//xsd:element[@name='Order']//xsd:attribute[@name='position']//xsd:maxInclusive/@value
198 "/>
199 </xsl:call-template>
200
201</xsl:template>
202
203<!--
204 * aliases (defines) for individual OSTypeIds array elements
205-->
206<xsl:template match="xsd:schema" mode="declare">
207
208 <xsl:text>&#x0A; extern const char *OSTypeIds[];&#x0A;</xsl:text>
209
210 <xsl:text>&#x0A; enum { OSTypeId_COUNT = </xsl:text>
211 <xsl:value-of select="count (
212 xsd:simpleType[@name='TGuestOSType']/xsd:restriction[@base='xsd:string']/xsd:enumeration |
213 document(xsd:include[not(@schemaLocation='VirtualBox-settings-root.xsd')]/@schemaLocation)/xsd:schema/xsd:simpleType[@name='TGuestOSType']/xsd:restriction[@base='xsd:string']/xsd:enumeration
214 )"/>
215 <xsl:text> };&#x0A;&#x0A;</xsl:text>
216
217 <xsl:for-each select="
218 xsd:simpleType[@name='TGuestOSType']/xsd:restriction[@base='xsd:string']/xsd:enumeration |
219 document(xsd:include[not(@schemaLocation='VirtualBox-settings-root.xsd')]/@schemaLocation)/xsd:schema/xsd:simpleType[@name='TGuestOSType']/xsd:restriction[@base='xsd:string']/xsd:enumeration
220 ">
221 <xsl:text> #define SchemaDefs_OSTypeId_</xsl:text>
222 <xsl:value-of select="@value"/>
223 <xsl:text> SchemaDefs::OSTypeIds [</xsl:text>
224 <xsl:value-of select="position()-1"/>
225 <xsl:text>]&#x0A;</xsl:text>
226 </xsl:for-each>
227
228</xsl:template>
229
230<!--
231 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
232 * define mode (C++ source file)
233 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
234-->
235
236<xsl:template match="/" mode="define">
237<xsl:text>
238/*
239 * DO NOT EDIT.
240 *
241 * This source is automatically generated from the VirtualBox XML Settings
242 * Schema and contains selected schema constraints defined in C++.
243 */
244
245#include "SchemaDefs.h"
246
247namespace SchemaDefs
248{
249</xsl:text>
250
251<xsl:apply-templates select="xsd:schema" mode="define"/>
252
253<xsl:text>}
254</xsl:text>
255</xsl:template>
256
257<!--
258 * array of OSTypeIds
259-->
260<xsl:template match="xsd:schema" mode="define">
261 <xsl:text> const char *OSTypeIds[] =
262 {
263</xsl:text>
264 <xsl:for-each select="
265 xsd:simpleType[@name='TGuestOSType']/xsd:restriction[@base='xsd:string']/xsd:enumeration |
266 document(xsd:include[not(@schemaLocation='VirtualBox-settings-root.xsd')]/@schemaLocation)/xsd:schema/xsd:simpleType[@name='TGuestOSType']/xsd:restriction[@base='xsd:string']/xsd:enumeration
267 ">
268 <xsl:text> "</xsl:text>
269 <xsl:value-of select="@value"/>
270 <xsl:text>",
271</xsl:text>
272 </xsl:for-each>
273 <xsl:text> };
274</xsl:text>
275</xsl:template>
276
277<!--
278 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
279 * END
280 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
281-->
282
283</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