XML serialization |
For compatability reasons with the XML technology, TeXmacs also
supports the serialization of TeXmacs documents in the XML format.
However, the XML format is generally more verbose and less readable
than the default TeXmacs format. In order to save or load a file in
the XML format (using the .tmml extension), you may
use
It should be noticed that TeXmacs documents do not match a predefined DTD, since the appropriate DTD for a document depends on its style. The XML format therefore merely provides an XML representation for TeXmacs trees. The syntax has both been designed to be close to the tree structure and use conventional XML notations which are well supported by standard tools.
The leafs of TeXmacs trees are traslated from the universal TeXmacs encoding into Unicode. Characters without Unicode equivalents are represented as entities (in the future, we rather plan to create a tmsym tag for representing such characters).
Trees with a single child are simply represented by the corresponding XML tag. In the case when a tree has several children, then each child is enclosed into a tm-arg tag. For instance, sqrt (x + y) is simply represented as
<sqrt>y+z</sqrt>
whereas the fraction
1 |
2 |
<frac>
<tm-arg>1</tm-arg>
<tm-arg>2</tm-arg>
</frac>
In the above example, the whitespace is ignored. Whitespace may be preserved by setting the standard xml:space attribute to preserve.
Some tags are represented in a special way in XML. The
1 |
2 |
<frac><tm-arg>1</tm-arg><tm-arg>2</tm-arg></frac>+<sqrt>y+z</sqrt>
The
Ik ben de blauwbilgorgel.
Als ik niet wok of worgel,
is represented as
<quote-env>
<tm-par>
Ik ben de blauwbilgorgel.
</tm-par>
<tm-par>
Als ik niet wok of worgel,
</tm-par>
</quote-env>
A
some <with color="blue">blue</with> text
Conversily, TeXmacs provides the
some <mytag beast="heary">special</mytag> text
would be imported as “some <my-tag|<attr|beast|heary>|special> text”. This will make it possible, in principle, to use TeXmacs as an editor of general XML files.