XML configuration syntax - ObjectVision/GeoDMS GitHub Wiki

The GeoDMS can read a configuration, or a part of one, written in XML instead of in the configuration file syntax. It is an alternative notation for the same tree of tree items, it is read by a reader of its own, and it is rarely used: almost every configuration is written in .dms syntax. It is described here because the reader ships with every version and a fragment can be included in any configuration.

including a fragment

An include statement whose file name ends in .xml is read by the XML reader instead of by the .dms parser. The fragment is added to the container the include statement appears in, exactly as a .dms include is:

container region_data
{
   #include <region.xml>
}

The folder rule is the same as for a .dms include: the included file lives in the subfolder named after the including configuration file, without its extension.

A whole configuration can also be written in XML and named on the command line:

GeoDmsRun.exe /Lrun.log region.xml /nr

The outermost element is then the configuration root, so its own name is not part of an item path, the same rule that holds for the top level container of a .dms configuration.

The GeoDMS GUI offers only .dms files in its open dialog, so an XML configuration is opened through the command line or through an include.

syntax

A fragment starts with a version header and holds one outermost element:

<?xml version="1.0"?>
<TreeItem name="region">
</TreeItem>

The markup is ordinary XML: spaces around <, ?, /, > and = are optional, an attribute value may be quoted with " or with ', and a tag may close itself with />. The spaced-out spelling of older fragments, with each of those characters on its own between spaces, is accepted as well; see files written by older versions.

The text between an opening and a closing tag is read as text, not as markup, so an expression inside an element needs no extra spaces.

That text is kept as it stands, apart from the whitespace before its first and after its last non-blank character, which is dropped; line ends are read the way XML prescribes, so a CRLF and a lone CR each count as one line end. A multi-line expression thus keeps its lines, and a value array keeps its alignment.

comments

A fragment may carry XML comments, wherever text or an element may stand:

<?xml version="1.0"?>
<TreeItem name="region">
   <!-- the study area, as delivered in 2026 -->
   <Descr>the study area</Descr>
</TreeItem>

They are skipped, not kept: a comment is gone from the tree, so writing the tree out again does not bring it back, exactly as in configuration file syntax.

items

Three element names create a tree item. Any other element is read as a property of the item that its enclosing element created.

element creates attributes
TreeItem a container or any other tree item name
unit a unit name, ValueType
DATAITEM a data item name, DomainUnit, ValuesUnit, ValueComposition

name is required on all three, and ValueType on a unit and ValuesUnit on a DATAITEM. A DATAITEM without a DomainUnit is a parameter: its domain is the void unit, the same item that parameter<uint32> x configures in .dms syntax.

A missing name, ValueType or ValuesUnit is reported as an error, a missing ValueType as Unknown ValueType ''.

properties

Every property is written as a child element, never as an attribute. <TreeItem name="x" Descr="..."> is refused with XML Element property Descr seen as attribute for x: TreeItem, and the same holds for StorageName and StorageType:

<TreeItem name="region">
   <Descr>the study area</Descr>
   <StorageType>gdal.vect</StorageType>
   <StorageName>%projDir%/data/region.gpkg</StorageName>
</TreeItem>

The exception is the handful of properties that a tree item fixes when it is created: name, ValueType, DomainUnit, ValuesUnit and ValueComposition. Those are attributes of the opening tag, as the table above says, and never child elements.

Writing one of them as a child element is refused, with names a property that cannot be set here: it is set at construction, from an attribute of the open tag; the same holds for a read-only property such as TableType.

entities

The XML entities &amp; &lt; &gt; &apos; &quot; are decoded in element text.

They are decoded in attribute values as well, and an attribute value is otherwise taken as it stands: a backslash, for instance, is an ordinary character and not the start of an escape. An unknown entity in an attribute value, such as &foo;, is kept as it stands.

Element text also decodes a numeric character reference, decimal &#65; or hexadecimal &#x42;, to the UTF-8 bytes of its character, and keeps an unknown entity such as &foo; as it stands, as an attribute value does.

writing a configuration as XML

A loaded configuration can be written back out in this notation. @dumpconfig chooses the notation from the extension of the file name it is given, so

GeoDmsRun.exe /Lrun.log region.dms @dumpconfig C:/tmp/region.xml

writes the tree as XML, where C:/tmp/region.dms would have written it in configuration file syntax. The same happens through DMS_TreeItem_Dump. What is written is the compact spelling of the syntax section, with the construction attributes in the opening tag and every other property as a child element.

That output can be read back. What survives the round trip is the tree: the same items, expressions, properties, units, templates, functions and configured value arrays. What does not survive is what the writer never writes: comments, and an #include, which is written inline rather than as a directive. Writing the same tree twice gives the same bytes, so one dump can be compared with a later one.

The notation has no declaration grammar for the function keyword, so a function item is written as a container with an extra FunctionSpec element that carries what makes it a function: the parameter count, the designated result, the type variables, the signature references and the variant flags. A template needs no such element: IsTemplate is an ordinary property.

A DomainUnit or ValuesUnit attribute names the unit as the source did when the source used a bare name, and otherwise by its path from the item, with a dot for every container up from the item (Parent item), such as .../geometries/rdc. The items of a function signature are the exception: a parameter, a member in the block of a parameter, and the result keep the spelling of the source, path or not, as a dump in configuration file syntax writes the signature. A unit in a signature is looked up from the function, never from where it is called, so both spellings name the same unit.

A configured value array is written in a DataBlock element. The same element carries an item that holds its values without having a rule for them, which is what the GeoDMS GUI writes when it saves a desktop. Such an item is written as a value array, so it reads back as one: that is the conversion that the configuration file syntax makes on a dump as well.

errors

An error inside an included fragment is reported in the eventlog as an [E] line, but it does not fail the load by itself. The run fails later, at the point where something refers to an item the fragment did not create. So when a fragment does not do what you expect, read the eventlog rather than the exit code.

An error in the markup names the file, the line and the column, and says what was expected:

[E] XML Error: .../region.xml(4, 14): the closing tag '</TreeItemm>' does not match the open tag '<TreeItem>'

The checks on the markup include the version header, a closing tag that does not match its open tag, a closing tag with an attribute, and the > after a / or a ?.

example

example.dms:

container region_data
{
   #include <region.xml>
   container checks
   {
      parameter<uint32> total := sum(region/nr), IntegrityCheck = "total == 33";
   }
}

example/region.xml, the subfolder named after the configuration file:

<?xml version="1.0"?>
<TreeItem name="region">
   <Descr>read from an xml fragment</Descr>
   <unit name="id" ValueType="uint32">
      <Expr>range(uint32, 0, 3)</Expr>
   </unit>
   <DATAITEM name="nr" DomainUnit="id" ValuesUnit="uint32">
      <Expr>id(id) + 10</Expr>
   </DATAITEM>
</TreeItem>

This configures the same tree as:

container region_data
{
   container region: Descr = "read from an xml fragment"
   {
      unit<uint32> id := range(uint32, 0, 3);
      attribute<uint32> nr (id) := id(id) + 10;
   }
}

files written by older versions

A GeoDMS before 20.20.0 split the markup on whitespace, so a fragment written for it has each of the characters <, ?, /, > and = on its own between spaces:

<? xml version = "1.0" ? >
< TreeItem name = "region" >
< / TreeItem >

That spelling still loads. In the other direction, a GeoDMS before 20.20.0 stops on the compact spelling with FormattedInpStream Error: expected '=', and fails on a comment as well. A GeoDMS from 20.20.0 up to, but not including, 20.23.1 hangs while loading a fragment with an entity in an attribute value, such as the &amp; and &quot; that the XML writer itself produces.

An XML dump written by a GeoDMS before 20.20.0 lacks part of the tree: a function is a plain container with IsTemplate = "True", without its parameters or its result; a configured value array is text inside the item element, which the reader ignores, so that the item reports No calculation rule or storage manager was specified; and an item that holds its values without a rule is a DATA element, which the reader does not take back either. Write such a configuration out again from its .dms source.

A GeoDMS before 20.20.0 also dropped the character right after an entity in element text, so a &amp; b gave a &b. A fragment that compensated for that by doubling the character after an entity has one character too many; remove the extra character.

⚠️ **GitHub.com Fallback** ⚠️