Table of Contents
L3DT's XML formatsL3DT uses the eXtensible Markup Language to store settings in text files, such as the project file (.proj), climate file (.cli.xml), and the application settings file (.ini.xml). Because I like writing code, I've made my own XML writer and parser. However, since I'm not a total masochist, I have not implemented the entire XML standard in L3DT's parser. Therefore, if you intent to write XML files for L3DT to read (for example, writing your own climate editor), you must conform to several requirements regarding the XML declaration, document type definition, element declarations, and case sensitivity. An example file is provided below. Example fileBelow is an example XML project file written by L3DT: <?xml version="1.0" encoding="utf-8"?> <varlist name="ProjectData"> <varlist name="MapInfo"> <varlist name="Terrain"> <int name="nx">1024</int> <int name="ny">1024</int> <float name="HorizScale">10.000000</float> </varlist> <varlist name="Texture"> <int name="nx">4096</int> <int name="ny">4096</int> </varlist> <bool name="WrapFlag">false</bool> </varlist> <varlist name="Files"> <varlist name="Maps"> <string name="DM">temp1_DM.dmf</string> <string name="HF">temp1_HF.hff</string> <string name="WM">temp1_WM.wmf</string> <string name="WS">temp1_WS.hff</string> <string name="AM">temp1_AM.amf</string> <string name="TN">temp1_TN.jpg</string> <string name="LM">LM\temp1_LM.mmf</string> <string name="TX">temp1_TX.jpg</string> </varlist> <varlist name="Climates"> <string name="Temperate">C:\L3DT\L3DT data path\Resources\Climates\Temperate24.cli.xml</string> <string name="Temperate (deluxe)">C:\L3DT\L3DT data path\Resources\Climates\Temperate (deluxe).cli.xml</string> </varlist> </varlist> </varlist> XML declarationL3DT does read the XML declaration, and actually cares about its content. Specifically:
Additonal attributes may be specified, but will be ignored by L3DT. Document type definitionThe XML parser in L3DT does not support document type definitions, and any such declaration will cause an error when reading the file. DTD's are not required by L3DT because the parser implements a very strict sub-set of XML with specific requirements on element types. Element declarationsElement declarations use the following prototype: <TYPE name = "NAME">DATA</TYPE> The restrictions on element types and element names are listed below. Supported element typesL3DT's XML format supports a limited number of element types, which are divided into the categories of data elements (which don't contain 'child' elements) and tree elements (which may contain 'child' elements). Data elements
Tree elements
Element namesNames of elements are specified using a 'name' attribute. For example: <string name="this is the name">this is the data</string> Forbidden charactersNames should be restricted to alphanumeric characters only (a-z, 0-9), although most symbols are supported. However, the following characters are explicitly forbidden in names:
Names must be unique within each levelElement names must be unique within each level of the document tree. For example, the following file is invalid: <varlist name = "list1"> <void name = "example"> <void name = "example"> </varlist> Whereas this is valid: <varlist name = "list1"> <void name = "example"/> </varlist> <varlist name = "list2"> <void name = "example"/> <!-- no longer in the same level as the other 'example' --> </varlist> Empty elementsIf an element contains no data, such as an empty string, L3DT's XML parser still requires both a start and an end tag for the element, and will not recognise a start tag that ends with a '/' (which normally signifies an empty element in HTML/XML). This is OK: <varlist name="empty list"></varlist>
This is not OK: <varlist name="empty list"/>
Whoops: there is one exception: elements of type 'void' can be terminated by a '/', because they inherently contain no data. Case sensitivityYup, that's right. L3DT's XML format is case senstive, which means that element tags must be in the same case as noted above. A 'varlist' is not the same as a 'VARLIST'. CommentsStandard XML comments are supported, using the syntax shown below: <!-- this is a comment -->
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|