[Lars H], 2010-02-03:
Some months ago, while working on [OpenMath] things, I grew tired of the [XML] syntax — it just felt cluttered and clumpsy with all those `>="'` characters. I wanted something more lightweight (for me as author), so where to turn, if not to [Tcl]? First for sketching things out, and later as a format that programs would actually process, I began to use something I dubbed TDL (for Tcl Data Language, or perhaps — in analogy with Tool Command Language and [Tool Protocol Language] — Tool Data Language).
First, an example to illustrate the idea. A small fragment of [OpenMath] is
This is rather cluttered. The same thing as TDL could be
OMA {
/OMS symocat1 label
/OMS Hopf-algebra mult
OMA {/OMS list1 list; /OMV a}
OMA {/OMS list1 list; /OMV b; /OMV c}
}
or if not so specialised
OMA {
OMS cd symocat1 name label
OMS cd Hopf-algebra name mult
OMA {OMS cd list1 name list; OMV name a}
OMA {
OMS cd list1 name list
OMV name b
OMV name c
}
}
** Basic principles **
1. A general XML element is transformed to a Tcl command with the
element name as command name, and the contents as a final "body"
argument. Other arguments must occur in pairs and encode the
attributes in the usual key–value style. Hence
is equivalent to
element attr1 val1 attr2 val2 {}
and also to
element attr1 val1 attr2 val2
since parity allows recognising the case of a missing body argument.
2. A sequence of XML elements is transformed to a sequence of commands,
i.e., to a script. Hence
is equivalent to
element1; element2 attr2 val2
and also to
element1
element2 attr2 val2
3. Command names which do not fit the XML syntax for element names
are used to express things other than elements and can have other
syntaxes, e.g. arguments identified by position. In particular,
the "/" command is used to encode character data in a sequence of
elements. Thus
3
can be encoded as
OMI {/ 3}
"/" can have any number of arguments, which are concatenated in the manner of [append].
4. Elements can sometimes be given an alternative encoding, in the form
of a positional command. These commands will usually have a "/"
prepended to the element name. The syntax is usually that required
attributes (if any) and character data contents (if any) are
mandatory arguments, but no general rule defining such commands
exist; each must be defined explicitly.
Example: The OM elements
5
could be expressed as
/OMS arith1 times
/OMV x
/OMI 5
but this would be context-dependent.
** Downside **
Some probably think it should be a criminal offense to invent a new syntax for XML, and there are no doubt interoperability problems lurking. On the other hand, if it allows me to be more productive, then I mostly think it is a good thing.
** Basic operations **
To be continued…
<> Category Data Serialization Format | Category XML