Changeset 7341 in vbox
- Timestamp:
- Mar 6, 2008 6:05:00 PM (17 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r7340 r7341 85 85 "<!-- innotek VirtualBox Machine Configuration -->" RTFILE_LINEFEED 86 86 "<VirtualBox xmlns=\"" VBOX_XML_NAMESPACE "\" " 87 "version=\"" VBOX_XML_VERSION "-" VBOX_XML_PLATFORM"\">" RTFILE_LINEFEED87 "version=\"" VBOX_XML_VERSION_FULL "\">" RTFILE_LINEFEED 88 88 "</VirtualBox>" RTFILE_LINEFEED 89 89 }; … … 1296 1296 1297 1297 mData->mConfigFileFull.cloneTo (aFilePath); 1298 return S_OK; 1299 } 1300 1301 STDMETHODIMP Machine:: 1302 COMGETTER(SettingsFileVersion) (BSTR *aSettingsFileVersion) 1303 { 1304 if (!aSettingsFileVersion) 1305 return E_INVALIDARG; 1306 1307 AutoCaller autoCaller (this); 1308 CheckComRCReturnRC (autoCaller.rc()); 1309 1310 AutoReaderLock alock (this); 1311 1312 mData->mSettingsFileVersion.cloneTo (aSettingsFileVersion); 1298 1313 return S_OK; 1299 1314 } … … 2198 2213 2199 2214 /* save settings on success */ 2200 rc = VirtualBox::saveSettingsTree (tree, file); 2215 rc = VirtualBox::saveSettingsTree (tree, file, 2216 mData->mSettingsFileVersion); 2201 2217 CheckComRCReturnRC (rc); 2202 2218 } … … 3856 3872 XmlTreeBackend tree; 3857 3873 3858 rc = VirtualBox::loadSettingsTree_FirstTime (tree, file); 3874 rc = VirtualBox::loadSettingsTree_FirstTime (tree, file, 3875 mData->mSettingsFileVersion); 3859 3876 CheckComRCThrowRC (rc); 3860 3877 … … 5149 5166 5150 5167 /* save the settings on success */ 5151 rc = VirtualBox::saveSettingsTree (tree, file); 5168 rc = VirtualBox::saveSettingsTree (tree, file, 5169 mData->mSettingsFileVersion); 5152 5170 CheckComRCThrowRC (rc); 5153 5171 } … … 5228 5246 5229 5247 /* save settings on success */ 5230 rc = VirtualBox::saveSettingsTree (tree, file); 5248 rc = VirtualBox::saveSettingsTree (tree, file, 5249 mData->mSettingsFileVersion); 5231 5250 CheckComRCReturnRC (rc); 5232 5251 } … … 5837 5856 5838 5857 /* save settings on success */ 5839 rc = VirtualBox::saveSettingsTree (tree, file); 5858 rc = VirtualBox::saveSettingsTree (tree, file, 5859 mData->mSettingsFileVersion); 5840 5860 CheckComRCReturnRC (rc); 5841 5861 } -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r7233 r7341 78 78 "<!-- innotek VirtualBox Global Configuration -->" RTFILE_LINEFEED 79 79 "<VirtualBox xmlns=\"" VBOX_XML_NAMESPACE "\" " 80 "version=\"" VBOX_XML_VERSION "-" VBOX_XML_PLATFORM"\">" RTFILE_LINEFEED80 "version=\"" VBOX_XML_VERSION_FULL "\">" RTFILE_LINEFEED 81 81 " <Global>"RTFILE_LINEFEED 82 82 " <MachineRegistry/>"RTFILE_LINEFEED … … 91 91 Bstr VirtualBox::sVersion; 92 92 93 // static 94 Bstr VirtualBox::sSettingsFormatVersion; 95 93 96 // constructor / destructor 94 97 ///////////////////////////////////////////////////////////////////////////// … … 139 142 sVersion = VBOX_VERSION_STRING; 140 143 LogFlowThisFunc (("Version: %ls\n", sVersion.raw())); 144 145 if (sSettingsFormatVersion.isNull()) 146 sSettingsFormatVersion = VBOX_XML_VERSION_FULL; 147 LogFlowThisFunc (("Settings Format Version: %ls\n", 148 sSettingsFormatVersion.raw())); 141 149 142 150 /* Get the VirtualBox home directory. */ … … 201 209 XmlTreeBackend tree; 202 210 203 rc = VirtualBox::loadSettingsTree_FirstTime (tree, file); 211 rc = VirtualBox::loadSettingsTree_FirstTime (tree, file, 212 mData.mSettingsFileVersion); 204 213 CheckComRCThrowRC (rc); 205 214 … … 452 461 CheckComRCReturnRC (autoCaller.rc()); 453 462 463 /* mHomeDir is const and doesn't need a lock */ 454 464 mData.mHomeDir.cloneTo (aHomeFolder); 465 return S_OK; 466 } 467 468 STDMETHODIMP VirtualBox::COMGETTER(SettingsFilePath) (BSTR *aSettingsFilePath) 469 { 470 if (!aSettingsFilePath) 471 return E_INVALIDARG; 472 473 AutoCaller autoCaller (this); 474 CheckComRCReturnRC (autoCaller.rc()); 475 476 /* mCfgFile.mName is const and doesn't need a lock */ 477 mData.mCfgFile.mName.cloneTo (aSettingsFilePath); 478 return S_OK; 479 } 480 481 STDMETHODIMP VirtualBox:: 482 COMGETTER(SettingsFileVersion) (BSTR *aSettingsFileVersion) 483 { 484 if (!aSettingsFileVersion) 485 return E_INVALIDARG; 486 487 AutoCaller autoCaller (this); 488 CheckComRCReturnRC (autoCaller.rc()); 489 490 AutoReaderLock alock (this); 491 492 mData.mSettingsFileVersion.cloneTo (aSettingsFileVersion); 493 return S_OK; 494 } 495 496 STDMETHODIMP VirtualBox:: 497 COMGETTER(SettingsFormatVersion) (BSTR *aSettingsFormatVersion) 498 { 499 if (!aSettingsFormatVersion) 500 return E_INVALIDARG; 501 502 AutoCaller autoCaller (this); 503 CheckComRCReturnRC (autoCaller.rc()); 504 505 sSettingsFormatVersion.cloneTo (aSettingsFormatVersion); 455 506 return S_OK; 456 507 } … … 1880 1931 1881 1932 /* save settings on success */ 1882 rc = VirtualBox::saveSettingsTree (tree, file); 1933 rc = VirtualBox::saveSettingsTree (tree, file, 1934 mData.mSettingsFileVersion); 1883 1935 CheckComRCReturnRC (rc); 1884 1936 } … … 2089 2141 { 2090 2142 return E_NOTIMPL; 2143 } 2144 2145 STDMETHODIMP VirtualBox::SaveSettings() 2146 { 2147 return saveSettings(); 2091 2148 } 2092 2149 … … 3720 3777 3721 3778 /* save the settings on success */ 3722 rc = VirtualBox::saveSettingsTree (tree, file); 3779 rc = VirtualBox::saveSettingsTree (tree, file, 3780 mData.mSettingsFileVersion); 3723 3781 CheckComRCThrowRC (rc); 3724 3782 } … … 4108 4166 * values for for missing attributes that have 4109 4167 * defaults in the XML schema. 4168 * @param aFormatVersion Where to store the current format version of the 4169 * loaded settings tree (optional, may be NULL). 4110 4170 */ 4111 4171 /* static */ … … 4114 4174 bool aValidate, 4115 4175 bool aCatchLoadErrors, 4116 bool aAddDefaults) 4176 bool aAddDefaults, 4177 Utf8Str *aFormatVersion /* = NULL */) 4117 4178 { 4118 4179 using namespace settings; … … 4120 4181 try 4121 4182 { 4122 SettingsInputResolver resolver = SettingsInputResolver(); 4123 4124 aTree.setInputResolver (resolver); 4183 SettingsTreeHelper helper = SettingsTreeHelper(); 4184 4185 aTree.setInputResolver (helper); 4186 aTree.setAutoConverter (helper); 4187 4125 4188 aTree.read (aFile, aValidate ? VBOX_XML_SCHEMA : NULL, 4126 4189 aAddDefaults ? XmlTreeBackend::Read_AddDefaults : 0); 4190 4191 aTree.resetAutoConverter(); 4127 4192 aTree.resetInputResolver(); 4193 4194 /* on success, memorize the current settings file version or set it to 4195 * the most recent version if no settings conversion took place. Note 4196 * that it's not necessary to do it every time we load the settings file 4197 * (i.e. only loadSettingsTree_FirstTime() passes a non-NULL 4198 * aFormatVersion value) because currently we keep the settings 4199 * files locked so that the only legal way to change the format version 4200 * while VirtualBox is running is saveSettingsTree(). */ 4201 if (aFormatVersion != NULL) 4202 { 4203 *aFormatVersion = aTree.oldVersion(); 4204 if (aFormatVersion->isNull()) 4205 *aFormatVersion = VBOX_XML_VERSION_FULL; 4206 } 4128 4207 } 4129 4208 catch (const EIPRTFailure &err) … … 4159 4238 * throw something. 4160 4239 * 4161 * @param aTree Tree to save. 4162 * @param aFile File to save the tree to. 4240 * @param aTree Tree to save. 4241 * @param aFile File to save the tree to. 4242 * @param aFormatVersion Where to store the (recent) format version of the 4243 * saved settings tree on success. 4163 4244 */ 4164 4245 /* static */ 4165 4246 HRESULT VirtualBox::saveSettingsTree (settings::TreeBackend &aTree, 4166 settings::File &aFile) 4247 settings::File &aFile, 4248 Utf8Str &aFormatVersion) 4167 4249 { 4168 4250 using namespace settings; … … 4171 4253 { 4172 4254 aTree.write (aFile); 4255 4256 /* set the current settings file version to the most recent version on 4257 * success. See also VirtualBox::loadSettingsTree(). */ 4258 if (aFormatVersion != VBOX_XML_VERSION_FULL) 4259 aFormatVersion = VBOX_XML_VERSION_FULL; 4173 4260 } 4174 4261 catch (const EIPRTFailure &err) -
trunk/src/VBox/Main/VirtualBoxImplExtra.cpp
r6124 r7341 31 31 #include "xml_SettingsConverter_xsl.h" 32 32 33 /** 33 /** 34 34 * Resolves external entities while parting and validating XML settings files. 35 * 35 * 36 36 * @param aURI URI of the external entity. 37 37 * @param aID ID of the external entity (may be NULL). 38 * 38 * 39 39 * @return Input stream created using @c new or NULL to indicate 40 40 * a wrong URI/ID pair. 41 41 */ 42 42 settings::Input * 43 VirtualBox::Settings InputResolver::resolveEntity (const char *aURI, const char *aID)43 VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID) 44 44 { 45 45 if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0) … … 57 57 } 58 58 59 if (strcmp (aURI, VBOX_XML_SETTINGS_CONVERTER) == 0) 60 { 61 return new settings:: 62 MemoryBuf ((const char *) g_ab_xml_SettingsConverter_xsl, 63 g_cb_xml_SettingsConverter_xsl, aURI); 64 } 65 59 66 AssertMsgFailed (("Unexpected entity: '%s' - knows: '%s' and '%s'\n", aURI, 60 67 VBOX_XML_SCHEMA_COMMON, VBOX_XML_SCHEMA)); 61 68 return NULL; 62 69 } 70 71 /** 72 * Returns @true if the given tree needs to be converted using the XSLT 73 * template identified by #templateUri(), or @false if no conversion is 74 * required. 75 * 76 * The implementation normally checks for the "version" value of the 77 * root key to determine if the conversion is necessary. The 78 * implementation must return a string representing the old version 79 * (before conversion) in the @c aOldVersion argument -- this string is 80 * used by XmlTreeBackend::oldVersion() and must be non-NULL to indicate 81 * that the conversion has been performed on the tree. The returned 82 * string must be allocated using RTStrDup or such. 83 * 84 * @param aRoot Root settings key. 85 * @param aOldVersionString Old version string (allocated by 86 * RTStrDup or such). 87 */ 88 bool VirtualBox::SettingsTreeHelper:: 89 needsConversion (const settings::Key &aRoot, char *&aOldVersion) const 90 { 91 if (strcmp (aRoot.name(), "VirtualBox") == 0) 92 { 93 const char *version = aRoot.stringValue ("version"); 94 const char *dash = strchr (version, '-'); 95 if (dash != NULL && strcmp (dash + 1, VBOX_XML_PLATFORM) == 0) 96 { 97 if (strcmp (version, VBOX_XML_VERSION_FULL) != 0) 98 { 99 /* version mismatch */ 100 aOldVersion = RTStrDup (version); 101 return true; 102 } 103 } 104 } 105 106 /* either the tree is invalid, or it's the other platform, or it's the same 107 * version */ 108 return false; 109 } 110 111 /** 112 * Returns the URI of the XSLT template to perform the conversion. 113 * This template will be applied to the tree if #needsConversion() 114 * returns @c true for this tree. 115 */ 116 const char *VirtualBox::SettingsTreeHelper::templateUri() const 117 { 118 return VBOX_XML_SETTINGS_CONVERTER; 119 } 120 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r7283 r7341 877 877 <interface 878 878 name="IVirtualBox" extends="$dispatched" 879 uuid=" 64f652cb-7fdf-482d-ae19-4dbb289a5ca0"879 uuid="3d835db8-0d0b-4d3e-a83e-ed1dea86c4f5" 880 880 wsmap="managed" 881 881 > … … 916 916 places where relative paths are allowed (unless otherwise 917 917 expressly indicated). 918 </desc> 919 </attribute> 920 921 <attribute name="settingsFilePath" type="wstring" readonly="yes"> 922 <desc> 923 Full name of the global settings file. 924 The value of this property corresponds to the value of 925 <link to="#homeFolder"/> plus <tt>/VirtualBox.xml</tt>. 926 </desc> 927 </attribute> 928 929 <attribute name="settingsFileVersion" type="wstring" readonly="yes"> 930 <desc> 931 Current version of the format of the global VirtualBox settings file 932 (<tt>VirtualBox.xml</tt>). 933 934 The version string has the following format: 935 <pre>x.y-platform</pre> 936 where <tt>x</tt> and <tt>y</tt> are the major and the minor format 937 versions, and <tt>platform</tt> is the platform identifier. 938 939 The current version usually matches the value of the 940 <link to="#settingsFormatVersion"/> attribute unless the 941 settings file was created by an older version of VirtualBox and there 942 was a change of the settings file format since then. 943 944 Note that VirtualBox automatically converts settings files from older 945 versions to the most recent version when reading them (usually at 946 VirtualBox startup) but it doesn't save the changes back until 947 you call a method that implicitly saves settings (such as 948 <link to="#setExtraData()"/>) or call <link to="#saveSettings()"/> 949 explicitly. Therefore, if the value of this attribute differs from the 950 value of <link to="#settingsFormatVersion"/>, then it 951 means that the settings file was converted but the result of the 952 conversion is not yet saved to disk. 953 954 The above feature may be used by interactive front-ends to inform users 955 about the settings file format change and offer them to explicitly save 956 all converted settings files (the global and VM-specific ones), 957 optionally create bacup copies of the old settings files before saving, 958 etc. 959 960 <see>settingsFormatVersion</see> 961 </desc> 962 </attribute> 963 964 <attribute name="settingsFormatVersion" type="wstring" readonly="yes"> 965 <desc> 966 Most recent version of the settings file format. 967 968 The version string has the following format: 969 <pre>x.y-platform</pre> 970 where <tt>x</tt> and <tt>y</tt> are the major and the minor format 971 versions, and <tt>platform</tt> is the platform identifier. 972 973 VirtualBox uses this version of the format when saving settings files 974 (either as a result of method calls that require to save settings or as 975 a result of an explicit call to <link to="#saveSettings()"/>). 976 977 <see>settingsFileVersion</see> 918 978 </desc> 919 979 </attribute> … … 2029 2089 </method> 2030 2090 2091 <method name="saveSettings"> 2092 <desc> 2093 Saves the global settings to the global settings file 2094 (<link to="#settingsFilePath"/>). 2095 2096 This method is only useful for explicitly saving the global settings 2097 file after it has been auto-converted from the old format to the most 2098 recent format (see <link to="#settingsFileVersion"/> for details). 2099 Normally, the global settings file is implicitly saved when a global 2100 setting is changed. 2101 </desc> 2102 </method> 2103 2031 2104 </interface> 2032 2105 … … 2357 2430 <interface 2358 2431 name="IMachine" extends="$unknown" 2359 uuid=" 2830ce8c-be5b-4660-b8d5-65d913005b4f"2432 uuid="c929abcc-5373-4ed9-9b56-201430b37868" 2360 2433 wsmap="managed" 2361 2434 > … … 2654 2727 </attribute> 2655 2728 2729 <attribute name="settingsFileVersion" type="wstring" readonly="yes"> 2730 <desc> 2731 Current version of the format of the settings file of this machine 2732 (<link to="#settingsFilePath"/>). 2733 2734 The version string has the following format: 2735 <pre>x.y-platform</pre> 2736 where <tt>x</tt> and <tt>y</tt> are the major and the minor format 2737 versions, and <tt>platform</tt> is the platform identifier. 2738 2739 The current version usually matches the value of the 2740 <link to="IVirtualBox::settingsFormatVersion"/> attribute unless the 2741 settings file was created by an older version of VirtualBox and there 2742 was a change of the settings file format since then. 2743 2744 Note that VirtualBox automatically converts settings files from older 2745 versions to the most recent version when reading them (usually at 2746 VirtualBox startup) but it doesn't save the changes back until 2747 you call a method that implicitly saves settings (such as 2748 <link to="#setExtraData()"/>) or call <link to="#saveSettings()"/> 2749 explicitly. Therefore, if the value of this attribute differs from the 2750 value of <link to="IVirtualBox::settingsFormatVersion"/>, then it 2751 means that the settings file was converted but the result of the 2752 conversion is not yet saved to disk. 2753 2754 The above feature may be used by interactive front-ends to inform users 2755 about the settings file format change and offer them to explicitly save 2756 all converted settings files (the global and VM-specific ones), 2757 optionally create bacup copies of the old settings files before saving, 2758 etc. 2759 2760 <see>IVirtualBox::settingsFormatVersion</see> 2761 </desc> 2762 </attribute> 2763 2656 2764 <attribute name="settingsModified" type="boolean" readonly="yes"> 2657 2765 <desc> -
trunk/src/VBox/Main/include/MachineImpl.h
r7207 r7341 137 137 Bstr mConfigFile; 138 138 Bstr mConfigFileFull; 139 140 Utf8Str mSettingsFileVersion; 139 141 140 142 BOOL mAccessible; … … 465 467 STDMETHOD(COMGETTER(USBController)) (IUSBController * *aUSBController); 466 468 STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aFilePath); 469 STDMETHOD(COMGETTER(SettingsFileVersion)) (BSTR *aSettingsFileVersion); 467 470 STDMETHOD(COMGETTER(SettingsModified)) (BOOL *aModified); 468 471 STDMETHOD(COMGETTER(SessionState)) (SessionState_T *aSessionState); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r6909 r7341 109 109 STDMETHOD(COMGETTER(Version)) (BSTR *aVersion); 110 110 STDMETHOD(COMGETTER(HomeFolder)) (BSTR *aHomeFolder); 111 STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aSettingsFilePath); 112 STDMETHOD(COMGETTER(SettingsFileVersion)) (BSTR *aSettingsFileVersion); 113 STDMETHOD(COMGETTER(SettingsFormatVersion)) (BSTR *aSettingsFormatVersion); 111 114 STDMETHOD(COMGETTER(Host)) (IHost **aHost); 112 115 STDMETHOD(COMGETTER(SystemProperties)) (ISystemProperties **aSystemProperties); … … 179 182 BSTR *aChanged, BSTR *aValues); 180 183 184 STDMETHOD(SaveSettings)(); 185 181 186 /* public methods only for internal purposes */ 182 187 … … 257 262 const Bstr &settingsFileName() { return mData.mCfgFile.mName; } 258 263 259 class SettingsInputResolver : public settings::XmlTreeBackend::InputResolver 264 class SettingsTreeHelper : public settings::XmlTreeBackend::InputResolver 265 , public settings::XmlTreeBackend::AutoConverter 260 266 { 261 267 public: 262 268 269 // InputResolver interface 263 270 settings::Input *resolveEntity (const char *aURI, const char *aID); 271 272 // AutoConverter interface 273 bool needsConversion (const settings::Key &aRoot, char *&aOldVersion) const; 274 const char *templateUri() const; 264 275 }; 265 276 … … 268 279 bool aValidate, 269 280 bool aCatchLoadErrors, 270 bool aAddDefaults); 281 bool aAddDefaults, 282 Utf8Str *aFormatVersion = NULL); 271 283 272 284 /** … … 275 287 * Used when the settings file is to be loaded for the first time for the 276 288 * given object in order to recreate it from the stored settings. 289 * 290 * @param aFormatVersion Where to store the current format version of the 291 * loaded settings tree. 277 292 */ 278 293 static HRESULT loadSettingsTree_FirstTime (settings::XmlTreeBackend &aTree, 279 settings::File &aFile) 280 { 281 return loadSettingsTree (aTree, aFile, true, true, true); 294 settings::File &aFile, 295 Utf8Str &aFormatVersion) 296 { 297 return loadSettingsTree (aTree, aFile, true, true, true, 298 &aFormatVersion); 282 299 } 283 300 … … 310 327 311 328 static HRESULT saveSettingsTree (settings::TreeBackend &aTree, 312 settings::File &aFile); 329 settings::File &aFile, 330 Utf8Str &aFormatVersion); 313 331 314 332 static HRESULT handleUnexpectedExceptions (RT_SRC_POS_DECL); … … 389 407 390 408 CfgFile mCfgFile; 409 410 Utf8Str mSettingsFileVersion; 391 411 392 412 MachineList mMachines; … … 445 465 446 466 static Bstr sVersion; 467 static Bstr sSettingsFormatVersion; 447 468 448 469 static DECLCALLBACK(int) ClientWatcher (RTTHREAD thread, void *pvUser); -
trunk/src/VBox/Main/include/VirtualBoxXMLUtil.h
r6076 r7341 24 24 #define VBOX_XML_NAMESPACE "http://www.innotek.de/VirtualBox-settings" 25 25 26 /** VirtualBox XML settings version number substring ("x.y") */ 26 27 #define VBOX_XML_VERSION "1.2" 27 28 28 /** VirtualBox XML settings version string */29 /** VirtualBox XML settings version platform substring */ 29 30 #if defined (RT_OS_DARWIN) 30 31 # define VBOX_XML_PLATFORM "macosx" … … 47 48 #endif 48 49 50 /** VirtualBox XML settings full version string ("x.y-platform") */ 51 #define VBOX_XML_VERSION_FULL VBOX_XML_VERSION "-" VBOX_XML_PLATFORM 52 49 53 /** VirtualBox XML common settings version string */ 50 54 #define VBOX_XML_PLATFORM_COMMON "common" … … 54 58 #define VBOX_XML_SCHEMA_COMMON "VirtualBox-settings-" VBOX_XML_PLATFORM_COMMON ".xsd" 55 59 60 /** VirtualBox XML settings converter file */ 61 #define VBOX_XML_SETTINGS_CONVERTER "SettingsConverter.xsl" 62 56 63 #endif /* ____H_VIRTUALBOXXMLUTIL */ -
trunk/src/VBox/Main/xml/SettingsConverter.xsl
r5999 r7341 7 7 * Template to convert old VirtualBox settings files to the most recent format. 8 8 9 Copyright (C) 2006-200 7innotek GmbH10 9 Copyright (C) 2006-2008 innotek GmbH 10 11 11 This file is part of VirtualBox Open Source Edition (OSE), as 12 12 available from http://www.virtualbox.org. This file is free software; … … 30 30 <xsl:variable name="recentVer" select="1.2"/> 31 31 32 <xsl:variable name="curVer" select="substring-before(/ VirtualBox/@version, '-')"/>33 <xsl:variable name="curVerPlat" select="substring-after(/ VirtualBox/@version, '-')"/>34 <xsl:variable name="curVerFull" select="/ VirtualBox/@version"/>32 <xsl:variable name="curVer" select="substring-before(/vb:VirtualBox/@version, '-')"/> 33 <xsl:variable name="curVerPlat" select="substring-after(/vb:VirtualBox/@version, '-')"/> 34 <xsl:variable name="curVerFull" select="/vb:VirtualBox/@version"/> 35 35 36 36 <xsl:template match="/"> 37 <xsl:text>
</xsl:text> 38 <xsl:comment> Automatically converted from version <xsl:value-of select="$curVerFull"/> to version <xsl:value-of select="$recentVer"/> </xsl:comment> 39 <xsl:text>
</xsl:text> 37 <xsl:comment> Automatically converted from version '<xsl:value-of select="$curVerFull"/>' to version '<xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/>' </xsl:comment> 40 38 <xsl:copy> 41 39 <xsl:apply-templates select="@*|node()"/> … … 48 46 <xsl:template match="/comment()"> 49 47 <xsl:copy-of select="."/> 50 <xsl:text>
</xsl:text>51 48 </xsl:template> 52 49 … … 62 59 63 60 <!-- 64 * Forbid unsupported VirtualBox settings versions61 * Forbid all unsupported VirtualBox settings versions 65 62 --> 66 63 67 <xsl:template match="/ VirtualBox">64 <xsl:template match="/vb:VirtualBox"> 68 65 <xsl:if test="@version=concat($recentVer,'-',$curVerPlat)"> 69 <xsl:message terminate="yes">70 Cannot convert from version <xsl:value-of select="@version"/> to version <xsl:value-of select="$recentVer"/>!66 <xsl:message terminate="yes"> 67 Cannot convert settings from version '<xsl:value-of select="@version"/>' to version '<xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/>'. 71 68 The source is already at the most recent version. 72 </xsl:message>69 </xsl:message> 73 70 </xsl:if> 74 71 <xsl:message terminate="yes"> 75 Cannot convert from version <xsl:value-of select="@version"/> to version <xsl:value-of select="$recentVer"/>!72 Cannot convert settings from version '<xsl:value-of select="@version"/>' to version '<xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/>'. 76 73 The source version is not supported. 77 74 </xsl:message> … … 79 76 80 77 <!-- 81 * Accept supported settings versions 78 * Accept supported settings versions (source setting filess to convert) 82 79 --> 83 <xsl:template match="/VirtualBox[@version='1.1-windows' or 84 @version='1.1-linux']"> 80 81 <!-- @todo temporary --> 82 <xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.999']"> 83 <xsl:copy> 84 <xsl:attribute name="version"><xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/></xsl:attribute> 85 <xsl:apply-templates select="node()"/> 86 </xsl:copy> 87 </xsl:template> 88 89 <xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.1']"> 85 90 <xsl:copy> 86 91 <xsl:attribute name="version"><xsl:value-of select="concat($recentVer,'-',$curVerPlat)"/></xsl:attribute> … … 91 96 <!-- 92 97 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 93 * Individual conver tions98 * Individual conversions 94 99 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 95 100 -->
Note:
See TracChangeset
for help on using the changeset viewer.