====== L3DT's XML formats ====== L3DT uses the [[wp>EXtensible_Markup_Language|eXtensible Markup Language]] to store settings in text files, such as the [[l3dt:formats:specs:proj|project file]] (.proj), [[l3dt:formats:specs:cli.xml|climate file]] (.cli.xml), and the [[l3dt:formats:specs:ini.xml|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 file ===== Below is an example XML [[l3dt:formats:specs:proj|project file]] written by L3DT: 1024 1024 10.000000 4096 4096 false temp1_DM.dmf temp1_HF.hff temp1_WM.wmf temp1_WS.hff temp1_AM.amf temp1_TN.jpg LM\temp1_LM.mmf temp1_TX.jpg C:\L3DT\L3DT data path\Resources\Climates\Temperate24.cli.xml C:\L3DT\L3DT data path\Resources\Climates\Temperate (deluxe).cli.xml ===== XML declaration ====== L3DT does read the XML declaration, and actually cares about its content. Specifically: * There must be a //version// attribute, which must have the value "1.0". * There must be an //encoding// attribute, which must have the value "utf-8" (not case-sensitive). Additonal attributes may be specified, but will be ignored by L3DT. ===== Document type definition ===== The XML parser in L3DT does not support [[wp>Document_Type_Definition|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 [[#supported element types|element types]]. ===== Element declarations ===== Element declarations use the following prototype: DATA The restrictions on [[#supported element types|element types]] and [[#element names]] are listed below. ==== Supported element types ==== L3DT'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 === ^ tag type ^ Example ^ Comments ^ | void | | Voids contain no data, and are used as flags. | | byte | 255 | 8-bit unsigned integer, values between 0 and 255. | | short | 32767 | 16-bit integer, values between -32768 and 32767. | | int | 1 | 32-bit integer, values between -2147483648 and 2147483647. | | int64 | 1 | 64-bit integer. | | float | 0.01 | Decimal and scientific notations are supported. | | double | 3E-120 | Same as float, but with greater precision. | | string | hello | Quotation marks are not required. | | DirSelector | C:\temp\temp.tmp | Used in L3DT to store and select directory names. See {{l3dt:formats:specs:paths.ini.xml}} example. | === Tree elements === ^ tag type ^ Comments ^ | varlist | Contains any number of other elements. | | buffer | Used in L3DT to store binary data (as hexidecimal text). | | FileConfig | Used in L3DT to store file format settings. See {{l3dt:formats:specs:formats.ini.xml}} example. | | FileSelector | Used in L3DT to store and select filenames. See {{l3dt:formats:specs:paths.ini.xml}} example. | | ComboSelector | Used in L3DT to store and select options from a list. See {{l3dt:formats:specs:formats.ini.xml}} example (specifically, RAW format). | ==== Element names ==== Names of elements are specified using a 'name' attribute. For example: this is the data === Forbidden characters === Names 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: * . -- //full-stop.// * " -- //quotation mark.// === Names must be unique within each level === Element names must be unique within each level of the document tree. For example, the following file is invalid: Whereas this is valid: ==== Empty elements ==== If 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: This is //not// OK: //Whoops: //there is one exception: elements of type 'void' can be terminated by a '/', because they inherently contain no data. ===== Case sensitivity ====== Yup, 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'. ===== Comments ====== Standard XML comments are supported, using the syntax shown below: