VirtualBox

source: vbox/trunk/src/VBox/Main/xml/SettingsConverter.xsl@ 17609

Last change on this file since 17609 was 15998, checked in by vboxsync, 16 years ago

Main/SettingsConverter: Fixed: Conversion fails on a virgin 1.3 VirtualBox.xml file due to an invalid defaultHardDiskFolder value.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.2 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 * :tabSize=2:indentSize=2:noTabs=true:
5 * :folding=explicit:collapseFolds=1:
6 *
7 * Template to convert old VirtualBox settings files to the most recent format.
8
9 Copyright (C) 2006-2008 Sun Microsystems, Inc.
10
11 This file is part of VirtualBox Open Source Edition (OSE), as
12 available from http://www.virtualbox.org. This file is free software;
13 you can redistribute it and/or modify it under the terms of the GNU
14 General Public License (GPL) as published by the Free Software
15 Foundation, in version 2 as it comes in the "COPYING" file of the
16 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18
19 Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 Clara, CA 95054 USA or visit http://www.sun.com if you need
21 additional information or have any questions.
22-->
23
24<xsl:stylesheet version="1.0"
25 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
26 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
27 xmlns:vb="http://www.innotek.de/VirtualBox-settings"
28 xmlns="http://www.innotek.de/VirtualBox-settings"
29 exclude-result-prefixes="#default vb xsl xsd"
30>
31
32<xsl:output method="xml" indent="yes"/>
33
34<xsl:variable name="curVer" select="substring-before(/vb:VirtualBox/@version, '-')"/>
35<xsl:variable name="curVerPlat" select="substring-after(/vb:VirtualBox/@version, '-')"/>
36<xsl:variable name="curVerFull" select="/vb:VirtualBox/@version"/>
37
38<xsl:template match="/">
39 <xsl:comment> Automatically converted from version '<xsl:value-of select="$curVerFull"/>' </xsl:comment>
40 <xsl:copy>
41 <xsl:apply-templates select="@*|node()"/>
42 </xsl:copy>
43</xsl:template>
44
45<!--
46 * comments outside the root node are gathered to a single line, fix this
47-->
48<xsl:template match="/comment()">
49 <xsl:copy-of select="."/>
50</xsl:template>
51
52<!--
53 * Forbid non-VirtualBox root nodes
54-->
55<xsl:template match="/*">
56 <xsl:message terminate="yes">
57Cannot convert an unknown XML file with the root node '<xsl:value-of select="name()"/>'!
58 </xsl:message>
59</xsl:template>
60
61<!--
62 * Forbid all unsupported VirtualBox settings versions
63-->
64<xsl:template match="/vb:VirtualBox">
65 <xsl:message terminate="yes">
66Cannot convert settings from version '<xsl:value-of select="@version"/>'.
67The source version is not supported.
68 </xsl:message>
69</xsl:template>
70
71<!--
72 * Accept supported settings versions (source setting files we can convert)
73 *
74 * Note that in order to simplify conversion from versions prior to the previous
75 * one, we support multi-step conversion like this: step 1: 1.0 => 1.1,
76 * step 2: 1.1 => 1.2, where 1.2 is the most recent version. If you want to use
77 * such multi-step mode, you need to ensure that only 1.0 => 1.1 is possible, by
78 * using the 'mode=1.1' attribute on both 'apply-templates' within the starting
79 * '/vb:VirtualBox[1.0]' template and within all templates that this
80 * 'apply-templates' should apply.
81 *
82 * If no 'mode' attribute is used as described above, then a direct conversion
83 * (1.0 => 1.2 in the above example) will happen when version 1.0 of the settings
84 * files is detected. Note that the direct conversion from pre-previous versions
85 * will require to patch their conversion templates so that they include all
86 * modifications from all newer versions, which is error-prone. It's better to
87 * use the milt-step mode.
88-->
89
90<!-- 1.1 => 1.2 -->
91<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.1']">
92 <xsl:copy>
93 <xsl:attribute name="version"><xsl:value-of select="concat('1.2','-',$curVerPlat)"/></xsl:attribute>
94 <xsl:apply-templates select="node()" mode="v1.2"/>
95 </xsl:copy>
96</xsl:template>
97
98<!-- 1.2 => 1.3.pre -->
99<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.2']">
100 <xsl:copy>
101 <xsl:attribute name="version"><xsl:value-of select="concat('1.3.pre','-',$curVerPlat)"/></xsl:attribute>
102 <xsl:apply-templates select="node()" mode="v1.3.pre"/>
103 </xsl:copy>
104</xsl:template>
105
106<!-- 1.3.pre => 1.3 -->
107<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.3.pre']">
108 <xsl:copy>
109 <xsl:attribute name="version"><xsl:value-of select="concat('1.3','-',$curVerPlat)"/></xsl:attribute>
110 <xsl:apply-templates select="node()" mode="v1.3"/>
111 </xsl:copy>
112</xsl:template>
113
114<!-- 1.3 => 1.4 -->
115<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.3']">
116 <xsl:copy>
117 <xsl:attribute name="version"><xsl:value-of select="concat('1.4','-',$curVerPlat)"/></xsl:attribute>
118 <xsl:apply-templates select="node()" mode="v1.4"/>
119 </xsl:copy>
120</xsl:template>
121
122<!-- 1.4 => 1.5 -->
123<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.4']">
124 <xsl:copy>
125 <xsl:attribute name="version"><xsl:value-of select="concat('1.5','-',$curVerPlat)"/></xsl:attribute>
126 <xsl:apply-templates select="node()" mode="v1.5"/>
127 </xsl:copy>
128</xsl:template>
129
130<!-- 1.5 => 1.6 -->
131<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.5']">
132 <xsl:copy>
133 <xsl:attribute name="version"><xsl:value-of select="concat('1.6','-',$curVerPlat)"/></xsl:attribute>
134 <xsl:apply-templates select="node()" mode="v1.6"/>
135 </xsl:copy>
136</xsl:template>
137
138
139<!--
140 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141 * 1.1 => 1.2
142 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143-->
144
145<!--
146 * all non-root elements that are not explicitly matched are copied as is
147-->
148<xsl:template match="@*|node()[../..]" mode="v1.2">
149 <xsl:copy>
150 <xsl:apply-templates select="@*|node()[../..]" mode="v1.2"/>
151 </xsl:copy>
152</xsl:template>
153
154<!--
155 * Global settings
156-->
157
158<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.1']/
159 vb:Global/vb:DiskImageRegistry/vb:HardDiskImages//
160 vb:Image"
161 mode="v1.2">
162 <DiffHardDisk>
163 <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute>
164 <VirtualDiskImage>
165 <xsl:attribute name="filePath"><xsl:value-of select="@src"/></xsl:attribute>
166 </VirtualDiskImage>
167 <xsl:apply-templates select="vb:Image"/>
168 </DiffHardDisk>
169</xsl:template>
170
171<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.1']/
172 vb:Global/vb:DiskImageRegistry"
173 mode="v1.2">
174<DiskRegistry>
175 <HardDisks>
176 <xsl:for-each select="vb:HardDiskImages/vb:Image">
177 <HardDisk>
178 <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute>
179 <xsl:attribute name="type">
180 <xsl:choose>
181 <xsl:when test="@independent='immutable'">immutable</xsl:when>
182 <xsl:when test="@independent='mutable'">immutable</xsl:when>
183 <xsl:otherwise>normal</xsl:otherwise>
184 </xsl:choose>
185 </xsl:attribute>
186 <VirtualDiskImage>
187 <xsl:attribute name="filePath"><xsl:value-of select="@src"/></xsl:attribute>
188 </VirtualDiskImage>
189 <xsl:apply-templates select="vb:Image"/>
190 </HardDisk>
191 </xsl:for-each>
192 </HardDisks>
193 <xsl:copy-of select="vb:DVDImages"/>
194 <xsl:copy-of select="vb:FloppyImages"/>
195</DiskRegistry>
196</xsl:template>
197
198<!--
199 * Machine settings
200-->
201
202<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.1']/
203 vb:Machine//vb:HardDisks"
204 mode="v1.2">
205 <HardDiskAttachments>
206 <xsl:for-each select="vb:HardDisk">
207 <HardDiskAttachment>
208 <xsl:attribute name="hardDisk"><xsl:value-of select="vb:Image/@uuid"/></xsl:attribute>
209 <xsl:apply-templates select="@*"/>
210 </HardDiskAttachment>
211 </xsl:for-each>
212 </HardDiskAttachments>
213</xsl:template>
214
215<!--
216 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
217 * 1.2 => 1.3.pre
218 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
219-->
220
221<!--
222 * all non-root elements that are not explicitly matched are copied as is
223-->
224<xsl:template match="@*|node()[../..]" mode="v1.3.pre">
225 <xsl:copy>
226 <xsl:apply-templates select="@*|node()[../..]" mode="v1.3.pre"/>
227 </xsl:copy>
228</xsl:template>
229
230<!--
231 * Global settings
232-->
233
234<!--
235 * Machine settings
236-->
237
238<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.2']/
239 vb:Machine//vb:USBController"
240 mode="v1.3.pre">
241 <xsl:copy>
242 <xsl:apply-templates select="@*|node()" mode="v1.3.pre"/>
243 </xsl:copy>
244 <SATAController enabled="false"/>
245</xsl:template>
246
247<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.2']/
248 vb:Machine//vb:HardDiskAttachments/vb:HardDiskAttachment"
249 mode="v1.3.pre">
250 <HardDiskAttachment>
251 <xsl:attribute name="hardDisk"><xsl:value-of select="@hardDisk"/></xsl:attribute>
252 <xsl:attribute name="bus">
253 <xsl:choose>
254 <xsl:when test="@bus='ide0'">
255 <xsl:text>IDE</xsl:text>
256 </xsl:when>
257 <xsl:when test="@bus='ide1'">
258 <xsl:text>IDE</xsl:text>
259 </xsl:when>
260 <xsl:otherwise>
261 <xsl:message terminate="yes">
262Value '<xsl:value-of select="@bus"/>' of 'HardDiskAttachment::bus' attribute is invalid.
263 </xsl:message>
264 </xsl:otherwise>
265 </xsl:choose>
266 </xsl:attribute>
267 <xsl:attribute name="channel">0</xsl:attribute>
268 <xsl:attribute name="device">
269 <xsl:choose>
270 <xsl:when test="@device='master'">
271 <xsl:text>0</xsl:text>
272 </xsl:when>
273 <xsl:when test="@device='slave'">
274 <xsl:text>1</xsl:text>
275 </xsl:when>
276 <xsl:otherwise>
277 <xsl:message terminate="yes">
278Value '<xsl:value-of select="@device"/>' of 'HardDiskAttachment::device' attribute is invalid.
279 </xsl:message>
280 </xsl:otherwise>
281 </xsl:choose>
282 </xsl:attribute>
283 </HardDiskAttachment>
284</xsl:template>
285
286<!--
287 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
288 * 1.3.pre => 1.3
289 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
290-->
291
292<!--
293 * all non-root elements that are not explicitly matched are copied as is
294-->
295<xsl:template match="@*|node()[../..]" mode="v1.3">
296 <xsl:copy>
297 <xsl:apply-templates select="@*|node()[../..]" mode="v1.3"/>
298 </xsl:copy>
299</xsl:template>
300
301<!--
302 * Global settings
303-->
304
305<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
306 vb:Global//vb:SystemProperties"
307 mode="v1.3">
308 <xsl:copy>
309 <xsl:apply-templates select="@*[not(name()='defaultSavedStateFolder')]|node()" mode="v1.3"/>
310 </xsl:copy>
311</xsl:template>
312
313<!--
314 * Machine settings
315-->
316
317<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
318 vb:Machine//vb:AudioAdapter"
319 mode="v1.3">
320 <xsl:if test="not(../vb:Uart)">
321 <UART/>
322 </xsl:if>
323 <xsl:if test="not(../vb:Lpt)">
324 <LPT/>
325 </xsl:if>
326 <xsl:copy>
327 <xsl:apply-templates select="@*[not(name()='driver')]|node()" mode="v1.3"/>
328 <xsl:attribute name="driver">
329 <xsl:choose>
330 <xsl:when test="@driver='null'">Null</xsl:when>
331 <xsl:when test="@driver='oss'">OSS</xsl:when>
332 <xsl:when test="@driver='alsa'">ALSA</xsl:when>
333 <xsl:when test="@driver='pulse'">Pulse</xsl:when>
334 <xsl:when test="@driver='coreaudio'">CoreAudio</xsl:when>
335 <xsl:when test="@driver='winmm'">WinMM</xsl:when>
336 <xsl:when test="@driver='dsound'">DirectSound</xsl:when>
337 <xsl:when test="@driver='solaudio'">SolAudio</xsl:when>
338 <xsl:when test="@driver='mmpm'">MMPM</xsl:when>
339 <xsl:otherwise>
340 <xsl:message terminate="yes">
341Value '<xsl:value-of select="@driver"/>' of 'AudioAdapter::driver' attribute is invalid.
342 </xsl:message>
343 </xsl:otherwise>
344 </xsl:choose>
345 </xsl:attribute>
346 </xsl:copy>
347 <xsl:if test="not(../vb:SharedFolders)">
348 <SharedFolders/>
349 </xsl:if>
350 <xsl:if test="not(../vb:Clipboard)">
351 <Clipboard mode="Disabled"/>
352 </xsl:if>
353 <xsl:if test="not(../vb:Guest)">
354 <Guest/>
355 </xsl:if>
356</xsl:template>
357
358<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
359 vb:Machine//vb:RemoteDisplay"
360 mode="v1.3">
361 <xsl:copy>
362 <xsl:apply-templates select="@*[not(name()='authType')]|node()" mode="v1.3"/>
363 <xsl:attribute name="authType">
364 <xsl:choose>
365 <xsl:when test="@authType='null'">Null</xsl:when>
366 <xsl:when test="@authType='guest'">Guest</xsl:when>
367 <xsl:when test="@authType='external'">External</xsl:when>
368 <xsl:otherwise>
369 <xsl:message terminate="yes">
370Value '<xsl:value-of select="@authType"/>' of 'RemoteDisplay::authType' attribute is invalid.
371 </xsl:message>
372 </xsl:otherwise>
373 </xsl:choose>
374 </xsl:attribute>
375 </xsl:copy>
376</xsl:template>
377
378<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
379 vb:Machine//vb:BIOS/vb:BootMenu"
380 mode="v1.3">
381 <xsl:copy>
382 <xsl:apply-templates select="@*[not(name()='mode')]|node()" mode="v1.3"/>
383 <xsl:attribute name="mode">
384 <xsl:choose>
385 <xsl:when test="@mode='disabled'">Disabled</xsl:when>
386 <xsl:when test="@mode='menuonly'">MenuOnly</xsl:when>
387 <xsl:when test="@mode='messageandmenu'">MessageAndMenu</xsl:when>
388 <xsl:otherwise>
389 <xsl:message terminate="yes">
390Value '<xsl:value-of select="@mode"/>' of 'BootMenu::mode' attribute is invalid.
391 </xsl:message>
392 </xsl:otherwise>
393 </xsl:choose>
394 </xsl:attribute>
395 </xsl:copy>
396</xsl:template>
397
398<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
399 vb:Machine//vb:USBController/vb:DeviceFilter |
400 vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
401 vb:Global/vb:USBDeviceFilters/vb:DeviceFilter"
402 mode="v1.3">
403 <xsl:copy>
404 <xsl:apply-templates select="node()" mode="v1.3"/>
405 <xsl:for-each select="@*">
406 <xsl:choose>
407 <xsl:when test="name()='vendorid'">
408 <xsl:attribute name="vendorId"><xsl:value-of select="."/></xsl:attribute>
409 </xsl:when>
410 <xsl:when test="name()='productid'">
411 <xsl:attribute name="productId"><xsl:value-of select="."/></xsl:attribute>
412 </xsl:when>
413 <xsl:when test="name()='serialnumber'">
414 <xsl:attribute name="serialNumber"><xsl:value-of select="."/></xsl:attribute>
415 </xsl:when>
416 <xsl:otherwise>
417 <xsl:apply-templates select="." mode="v1.3"/>
418 </xsl:otherwise>
419 </xsl:choose>
420 </xsl:for-each>
421 </xsl:copy>
422</xsl:template>
423
424<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
425 vb:Machine//vb:Guest"
426 mode="v1.3">
427 <xsl:copy>
428 <xsl:apply-templates select="node()" mode="v1.3"/>
429 <xsl:for-each select="@*">
430 <xsl:choose>
431 <xsl:when test="name()='MemoryBalloonSize'">
432 <xsl:attribute name="memoryBalloonSize"><xsl:value-of select="."/></xsl:attribute>
433 </xsl:when>
434 <xsl:when test="name()='StatisticsUpdateInterval'">
435 <xsl:attribute name="statisticsUpdateInterval"><xsl:value-of select="."/></xsl:attribute>
436 </xsl:when>
437 <xsl:otherwise>
438 <xsl:apply-templates select="node()" mode="v1.3"/>
439 </xsl:otherwise>
440 </xsl:choose>
441 </xsl:for-each>
442 </xsl:copy>
443</xsl:template>
444
445<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
446 vb:Machine//vb:Uart"
447 mode="v1.3">
448 <UART>
449 <xsl:apply-templates select="@*|node()" mode="v1.3"/>
450 </UART>
451</xsl:template>
452
453<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/
454 vb:Machine//vb:Lpt"
455 mode="v1.3">
456 <LPT>
457 <xsl:apply-templates select="@*|node()" mode="v1.3"/>
458 </LPT>
459</xsl:template>
460
461<!--
462 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
463 * 1.3 => 1.4
464 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
465-->
466
467<!--
468 * all non-root elements that are not explicitly matched are copied as is
469-->
470<xsl:template match="@*|node()[../..]" mode="v1.4">
471 <xsl:copy>
472 <xsl:apply-templates select="@*|node()[../..]" mode="v1.4"/>
473 </xsl:copy>
474</xsl:template>
475
476<!--
477 * Global settings
478-->
479
480<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
481 vb:Global/vb:DiskRegistry/vb:HardDisks/vb:HardDisk |
482 vb:VirtualBox[substring-before(@version,'-')='1.3']/
483 vb:Global/vb:DiskRegistry/vb:HardDisks//vb:DiffHardDisk"
484 mode="v1.4-HardDisk-format-location">
485 <xsl:attribute name="format">
486 <xsl:choose>
487 <xsl:when test="*[self::vb:VirtualDiskImage][1]">VDI</xsl:when>
488 <xsl:when test="*[self::vb:VMDKImage][1]">VMDK</xsl:when>
489 <xsl:when test="*[self::vb:VHDImage][1]">VHD</xsl:when>
490 <xsl:when test="*[self::vb:ISCSIHardDisk][1]">iSCSI</xsl:when>
491 <xsl:when test="*[self::vb:CustomHardDisk][1]">
492 <xsl:value-of select="@format"/>
493 </xsl:when>
494 <xsl:otherwise>
495 <xsl:message terminate="yes">
496Sub-element '<xsl:value-of select="name(*[1])"/>' of 'HardDisk' element is invalid.
497 </xsl:message>
498 </xsl:otherwise>
499 </xsl:choose>
500 </xsl:attribute>
501 <xsl:attribute name="location">
502 <xsl:choose>
503 <xsl:when test="*[self::vb:VirtualDiskImage][1]">
504 <xsl:value-of select="vb:VirtualDiskImage/@filePath"/>
505 </xsl:when>
506 <xsl:when test="*[self::vb:VMDKImage][1]">
507 <xsl:value-of select="vb:VMDKImage/@filePath"/>
508 </xsl:when>
509 <xsl:when test="*[self::vb:VHDImage][1]">
510 <xsl:value-of select="vb:VHDImage/@filePath"/>
511 </xsl:when>
512 <xsl:when test="*[self::vb:CustomHardDisk][1]">
513 <xsl:value-of select="vb:CustomHardDisk/@location"/>
514 </xsl:when>
515 <xsl:when test="*[self::vb:ISCSIHardDisk][1]">
516 <xsl:text>iscsi://</xsl:text>
517 <xsl:if test="vb:ISCSIHardDisk/@userName">
518 <xsl:value-of select="vb:ISCSIHardDisk/@userName"/>
519 <!-- note that for privacy reasons we don't show the password in the
520 location string -->
521 <xsl:text>@</xsl:text>
522 </xsl:if>
523 <xsl:if test="vb:ISCSIHardDisk/@server">
524 <xsl:value-of select="vb:ISCSIHardDisk/@server"/>
525 <xsl:if test="vb:ISCSIHardDisk/@port">
526 <xsl:value-of select="concat(':',vb:ISCSIHardDisk/@port)"/>
527 </xsl:if>
528 </xsl:if>
529 <xsl:if test="vb:ISCSIHardDisk/@target">
530 <xsl:value-of select="concat('/',vb:ISCSIHardDisk/@target)"/>
531 </xsl:if>
532 <xsl:if test="vb:ISCSIHardDisk/@lun">
533 <xsl:value-of select="concat('/enc',vb:ISCSIHardDisk/@lun)"/>
534 </xsl:if>
535 <xsl:if test="not(vb:ISCSIHardDisk/@server) or not(vb:ISCSIHardDisk/@target)">
536 <xsl:message terminate="yes">
537Required attribute 'server' or 'target' is missing from ISCSIHardDisk element!
538 </xsl:message>
539 </xsl:if>
540 </xsl:when>
541 </xsl:choose>
542 </xsl:attribute>
543 <xsl:if test="*[self::vb:ISCSIHardDisk][1]">
544 <xsl:choose>
545 <xsl:when test="vb:ISCSIHardDisk/@server and vb:ISCSIHardDisk/@port">
546 <xsl:element name="Property">
547 <xsl:attribute name="name">TargetAddress</xsl:attribute>
548 <xsl:attribute name="value">
549 <xsl:value-of select="concat(vb:ISCSIHardDisk/@server,
550 ':',vb:ISCSIHardDisk/@port)"/>
551 </xsl:attribute>
552 </xsl:element>
553 </xsl:when>
554 <xsl:when test="vb:ISCSIHardDisk/@server">
555 <xsl:element name="Property">
556 <xsl:attribute name="name">TargetAddress</xsl:attribute>
557 <xsl:attribute name="value">
558 <xsl:value-of select="vb:ISCSIHardDisk/@server"/>
559 </xsl:attribute>
560 </xsl:element>
561 </xsl:when>
562 </xsl:choose>
563 <xsl:if test="vb:ISCSIHardDisk/@target">
564 <xsl:element name="Property">
565 <xsl:attribute name="name">TargetName</xsl:attribute>
566 <xsl:attribute name="value">
567 <xsl:value-of select="vb:ISCSIHardDisk/@target"/>
568 </xsl:attribute>
569 </xsl:element>
570 </xsl:if>
571 <xsl:if test="vb:ISCSIHardDisk/@userName">
572 <xsl:element name="Property">
573 <xsl:attribute name="name">InitiatorUsername</xsl:attribute>
574 <xsl:attribute name="value">
575 <xsl:value-of select="vb:ISCSIHardDisk/@userName"/>
576 </xsl:attribute>
577 </xsl:element>
578 </xsl:if>
579 <xsl:if test="vb:ISCSIHardDisk/@password">
580 <xsl:element name="Property">
581 <xsl:attribute name="name">InitiatorSecret</xsl:attribute>
582 <xsl:attribute name="value">
583 <xsl:value-of select="vb:ISCSIHardDisk/@password"/>
584 </xsl:attribute>
585 </xsl:element>
586 </xsl:if>
587 <xsl:if test="vb:ISCSIHardDisk/@lun">
588 <xsl:element name="Property">
589 <xsl:attribute name="name">LUN</xsl:attribute>
590 <xsl:attribute name="value">
591 <xsl:value-of select="concat('enc',vb:ISCSIHardDisk/@lun)"/>
592 </xsl:attribute>
593 </xsl:element>
594 </xsl:if>
595 </xsl:if>
596</xsl:template>
597
598<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
599 vb:Global/vb:DiskRegistry/vb:HardDisks/vb:HardDisk"
600 mode="v1.4">
601 <HardDisk>
602 <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute>
603 <xsl:attribute name="type">
604 <xsl:choose>
605 <xsl:when test="@type='normal'">Normal</xsl:when>
606 <xsl:when test="@type='immutable'">Immutable</xsl:when>
607 <xsl:when test="@type='writethrough'">Writethrough</xsl:when>
608 <xsl:otherwise>
609 <xsl:message terminate="yes">
610Value '<xsl:value-of select="@type"/>' of 'HardDisk::type' attribute is invalid.
611 </xsl:message>
612 </xsl:otherwise>
613 </xsl:choose>
614 </xsl:attribute>
615 <xsl:apply-templates select="." mode="v1.4-HardDisk-format-location"/>
616 <xsl:apply-templates select="vb:DiffHardDisk" mode="v1.4"/>
617 </HardDisk>
618</xsl:template>
619
620<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
621 vb:Global/vb:DiskRegistry/vb:HardDisks/vb:HardDisk//
622 vb:DiffHardDisk"
623 mode="v1.4">
624 <HardDisk>
625 <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute>
626 <xsl:apply-templates select="." mode="v1.4-HardDisk-format-location"/>
627 <xsl:apply-templates select="vb:DiffHardDisk" mode="v1.4"/>
628 </HardDisk>
629</xsl:template>
630
631<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
632 vb:Global/vb:DiskRegistry/vb:DVDImages/vb:Image |
633 vb:VirtualBox[substring-before(@version,'-')='1.3']/
634 vb:Global/vb:DiskRegistry/vb:FloppyImages/vb:Image"
635 mode="v1.4">
636 <Image>
637 <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute>
638 <xsl:attribute name="location"><xsl:value-of select="@src"/></xsl:attribute>
639 </Image>
640</xsl:template>
641
642<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
643 vb:Global/vb:DiskRegistry"
644 mode="v1.4">
645 <MediaRegistry>
646 <HardDisks>
647 <xsl:apply-templates select="vb:HardDisks/vb:HardDisk" mode="v1.4"/>
648 </HardDisks>
649 <DVDImages>
650 <xsl:apply-templates select="vb:DVDImages/vb:Image" mode="v1.4"/>
651 </DVDImages>
652 <FloppyImages>
653 <xsl:apply-templates select="vb:FloppyImages/vb:Image" mode="v1.4"/>
654 </FloppyImages>
655 </MediaRegistry>
656</xsl:template>
657
658<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
659 vb:Global/vb:SystemProperties"
660 mode="v1.4">
661 <SystemProperties>
662 <xsl:apply-templates select="@*[not(name()='defaultVDIFolder')]|node()" mode="v1.4"/>
663 <!-- use the @defaultVDIFolder value for @defaultHardDiskFolder only when it
664 differs from the default (VDI) and otherwise simply delete it to let
665 VBoxSVC set the correct new default value -->
666 <xsl:if test="@defaultVDIFolder and not(translate(@defaultVDIFolder,'vdi','VDI')='VDI')">
667 <xsl:attribute name="defaultHardDiskFolder">
668 <xsl:value-of select="@defaultVDIFolder"/>
669 </xsl:attribute>
670 </xsl:if>
671 </SystemProperties>
672</xsl:template>
673
674<!--
675 * Machine settings
676-->
677
678 <xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/
679 vb:Machine/vb:Hardware"
680 mode="v1.4">
681 <!-- add version attribute to Hardware if parent Machine has a stateFile attribute -->
682 <xsl:copy>
683 <xsl:if test="../@stateFile">
684 <xsl:attribute name="version">1</xsl:attribute>
685 </xsl:if>
686 <xsl:apply-templates select="node()" mode="v1.4"/>
687 </xsl:copy>
688</xsl:template>
689
690
691<!--
692 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
693 * 1.4 => 1.5
694 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
695-->
696
697<!--
698 * all non-root elements that are not explicitly matched are copied as is
699-->
700<xsl:template match="@*|node()[../..]" mode="v1.5">
701 <xsl:copy>
702 <xsl:apply-templates select="@*|node()[../..]" mode="v1.5"/>
703 </xsl:copy>
704</xsl:template>
705
706<!--
707 * Global settings
708-->
709
710<!--
711 * Machine settings
712-->
713
714<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.4']/
715 vb:Machine"
716 mode="v1.5">
717 <xsl:copy>
718 <xsl:attribute name="OSType">
719 <xsl:choose>
720 <xsl:when test="@OSType='unknown'">Other</xsl:when>
721 <xsl:when test="@OSType='dos'">DOS</xsl:when>
722 <xsl:when test="@OSType='win31'">Windows31</xsl:when>
723 <xsl:when test="@OSType='win95'">Windows95</xsl:when>
724 <xsl:when test="@OSType='win98'">Windows98</xsl:when>
725 <xsl:when test="@OSType='winme'">WindowsMe</xsl:when>
726 <xsl:when test="@OSType='winnt4'">WindowsNT4</xsl:when>
727 <xsl:when test="@OSType='win2k'">Windows2000</xsl:when>
728 <xsl:when test="@OSType='winxp'">WindowsXP</xsl:when>
729 <xsl:when test="@OSType='win2k3'">Windows2003</xsl:when>
730 <xsl:when test="@OSType='winvista'">WindowsVista</xsl:when>
731 <xsl:when test="@OSType='win2k8'">Windows2008</xsl:when>
732 <xsl:when test="@OSType='os2warp3'">OS2Warp3</xsl:when>
733 <xsl:when test="@OSType='os2warp4'">OS2Warp4</xsl:when>
734 <xsl:when test="@OSType='os2warp45'">OS2Warp45</xsl:when>
735 <xsl:when test="@OSType='ecs'">OS2eCS</xsl:when>
736 <xsl:when test="@OSType='linux22'">Linux22</xsl:when>
737 <xsl:when test="@OSType='linux24'">Linux24</xsl:when>
738 <xsl:when test="@OSType='linux26'">Linux26</xsl:when>
739 <xsl:when test="@OSType='archlinux'">ArchLinux</xsl:when>
740 <xsl:when test="@OSType='debian'">Debian</xsl:when>
741 <xsl:when test="@OSType='opensuse'">OpenSUSE</xsl:when>
742 <xsl:when test="@OSType='fedoracore'">Fedora</xsl:when>
743 <xsl:when test="@OSType='gentoo'">Gentoo</xsl:when>
744 <xsl:when test="@OSType='mandriva'">Mandriva</xsl:when>
745 <xsl:when test="@OSType='redhat'">RedHat</xsl:when>
746 <xsl:when test="@OSType='ubuntu'">Ubuntu</xsl:when>
747 <xsl:when test="@OSType='xandros'">Xandros</xsl:when>
748 <xsl:when test="@OSType='freebsd'">FreeBSD</xsl:when>
749 <xsl:when test="@OSType='openbsd'">OpenBSD</xsl:when>
750 <xsl:when test="@OSType='netbsd'">NetBSD</xsl:when>
751 <xsl:when test="@OSType='netware'">Netware</xsl:when>
752 <xsl:when test="@OSType='solaris'">Solaris</xsl:when>
753 <xsl:when test="@OSType='opensolaris'">OpenSolaris</xsl:when>
754 <xsl:when test="@OSType='l4'">L4</xsl:when>
755 </xsl:choose>
756 </xsl:attribute>
757 <xsl:apply-templates select="@*[name()!='OSType']" mode="v1.5"/>
758 <xsl:apply-templates select="node()" mode="v1.5"/>
759 </xsl:copy>
760</xsl:template>
761
762<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.4']/
763 vb:Machine//vb:Hardware/vb:Display"
764 mode="v1.5">
765 <xsl:copy>
766 <xsl:apply-templates select="node()" mode="v1.5"/>
767 <xsl:for-each select="@*">
768 <xsl:choose>
769 <xsl:when test="name()='MonitorCount'">
770 <xsl:attribute name="monitorCount"><xsl:value-of select="."/></xsl:attribute>
771 </xsl:when>
772 <xsl:when test="name()='Accelerate3D'">
773 <xsl:attribute name="accelerate3D"><xsl:value-of select="."/></xsl:attribute>
774 </xsl:when>
775 <xsl:otherwise>
776 <xsl:apply-templates select="." mode="v1.5"/>
777 </xsl:otherwise>
778 </xsl:choose>
779 </xsl:for-each>
780 </xsl:copy>
781</xsl:template>
782
783<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.4']/
784 vb:Machine//vb:Hardware/vb:CPU"
785 mode="v1.5">
786 <xsl:copy>
787 <xsl:if test="vb:CPUCount/@count">
788 <xsl:attribute name="count"><xsl:value-of select="vb:CPUCount/@count"/></xsl:attribute>
789 </xsl:if>
790 <xsl:apply-templates select="@*" mode="v1.5"/>
791 <xsl:apply-templates select="node()[not(self::vb:CPUCount)]" mode="v1.5"/>
792 </xsl:copy>
793</xsl:template>
794
795
796<!--
797 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
798 * 1.5 => 1.6
799 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
800-->
801
802<!--
803 * all non-root elements that are not explicitly matched are copied as is
804-->
805<xsl:template match="@*|node()[../..]" mode="v1.6">
806 <xsl:copy>
807 <xsl:apply-templates select="@*|node()[../..]" mode="v1.6"/>
808 </xsl:copy>
809</xsl:template>
810
811<!--
812 * Global settings
813-->
814
815<!--
816 * Machine settings
817-->
818
819<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.5' and
820 not(substring-after(@version,'-')='windows')]/
821 vb:Machine//vb:Hardware/vb:Network/vb:Adapter/
822 vb:HostInterface[@TAPSetup or @TAPTerminate]"
823 mode="v1.6">
824 <!-- just remove the node -->
825</xsl:template>
826
827
828<!--
829 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
830-->
831
832
833<!-- @todo add lastStateChange with the current timestamp if missing.
834 * current-dateTime() is available only in XPath 2.0 so we will need to pass
835 * the current time as a parameter to the XSLT processor. -->
836<!--
837<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='Xo.Yo']/
838 vb:Machine"
839 mode="X.Y">
840 <xsl:copy>
841 <xsl:if test="not(@lastStateChange)">
842 <xsl:attribute name="lastStateChange">
843 <xsl:value-of select="current-dateTime()"/>
844 </xsl:attribute>
845 </xsl:if>
846 <xsl:apply-templates select="@*|node()" mode="vX.Y"/>
847 </xsl:copy>
848</xsl:template>
849-->
850
851</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