LavishSettings:XML

From Lavish Software Wiki
Jump to navigation Jump to search

Introduction

Why XML?

XML is selected as the general-use storage mechanism for LavishSettings because it is perfectly suited for the job. Its dynamic nature and tree structure make it the perfect fit.

XML vs .ini

.ini format was, in the past, a popular configuration file format on Windows. Fortunately, this is on its way out. Limitations in the .ini file format prevent it from being used with LavishSettings:

  1. Restrictions on set (section) names
  2. Restrictions on setting names
  3. Flat (no) hierarchy
  4. No clear UTF-8 support
  5. No well-defined standard format

All of the above problems are solved using XML.

Format

A LavishSettings XML file begins the same way any XML file does, with the <?xml?> tag containing the version and encoding used. When output by LavishSettings, the output then includes a comment with the LavishSettings version number. The outermost tag used by LavishSettings is application-defined, so the example below uses "InnerSpaceSettings" as is defined by Inner Space. Each Set is identified by a Set tag, containing the Name of the set as an attribute. Each Setting is identified by a Setting tag, also containing the Name of the setting as an attribute. The text value of the setting is contained within. Comments are identified in the standard XML way, with <!-- and -->. Only comments falling within the outermost tag will be retained by the settings system.

<?xml version='1.0' encoding='UTF-8'?>
<InnerSpaceSettings>
	<Set Name="User Interface">
		<Setting Name="Typematic Rate">33</Setting>
		<Setting Name="Typematic Delay">300</Setting>
		<Setting Name="Auto-Tooltip Delay">1000</Setting>
		<Setting Name="Double Click Time">500</Setting>
		<Set Name="Uplink">
			<Setting Name="Skin">Interface/DefaultSkin.xml</Setting>
			<Setting Name="Interface">Interface/DefaultUplinkUI.xml</Setting>
			<Setting Name="Patcher">Patcher</Setting>
			<Setting Name="Configuration">Configuration</Setting>
			<Set Name="Element Positions">
				<Set Name="console">
					<Setting Name="X">0</Setting>
					<Setting Name="Y">0</Setting>
					<!-- This is a comment -->
				</Set>
			</Set>
		</Set>
	</Set>
</InnerSpaceSettings>

See Also