Exporting a Dendros document to XML

Any Dendros document can be represented in XML, and such an XML document can be transformed into a valid Dendros document.


Consider this binary Dendros document:
Dendros v2.0 example document: CE BE CF 85 CE BB CE BF CE BD 02 00 0D 0A FF 0A 7B 0A 69 00 6D 00 61 00 67 00 65 00 7B 06 64 00 69 00 6D 00 7B 02 77 00 84 02 02 00 7D 7B 02 68 00 84 02 03 00 7D 7D 7B 08 64 00 61 00 74 00 61 00 82 12 11 11 11 12 12 12 21 21 21 22 22 22 31 31 31 32 32 32 7D 7D

Exported to valid XML the document would look like this:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE dendros [
<!ELEMENT value   (#PCDATA)>
<!ELEMENT element (element*|value*)>
<!ELEMENT dendros (element)>
<!ATTLIST dendros version CDATA #REQUIRED>
<!ATTLIST element name    CDATA #REQUIRED>
<!ATTLIST value   type    CDATA #REQUIRED>
<!ATTLIST value   code    CDATA #REQUIRED>
]>
<dendros version='2.0'>
<element name='image'>
<element name='dim'>
<element name='w'>
<value type='uint16' code='std'>2</value>
</element>
<element name='h'>
<value type='uint16' code='std'>3</value>
</element>
</element>
<element name='data'>
<value type='uint8' code='hex'>11 11 11 12 12 12 21 21 21 22 22 22 31 31 31 32 32 32</value>
</element>
</element>
</dendros>

 

The DTD for all XML encoded Dendros documents is as follows:
<!--                                                  -->
<!-- Minimalist DTD for XML encoded Dendros documents -->
<!--                                                  -->

<!ELEMENT value   (#PCDATA)>
<!ELEMENT element (element*|value*)>
<!ELEMENT dendros (element)>
<!ATTLIST dendros version CDATA #REQUIRED>
<!ATTLIST element name    CDATA #REQUIRED>
<!ATTLIST value   type    CDATA #REQUIRED>
<!ATTLIST value   code    CDATA #REQUIRED>

 


These XML elements represent the top-level Dendros components:
XML elementDescription
dendrosAn XML representation of a Dendros document.
elementAn XML representation of a Dendros element.
valueAn XML representation of a Dendros value.

These XML attributes must be used with the described XML elements:
XML elementXML attributeDescription
dendrosversionThe Dendros version of the XML encoded document.
elementnameThe Dendros element's name.
valuetypeSpecifies the data type, corresponding to the value_marker:

value_markertype attribute
81bool
82uint8
83sint8
84uint16
85sint16
86uint32
87sint32
88uint64
89sint64
8Afloat
8Bdouble
8Ctext
valuecodehex = binary representation
std = standard representation

 


The data items contained in value_data are separated by whitespace when represented in XML.

Examples of value_data representations:
type=code="std"code="hex"
boolfalse   true00   01
uint8160   80A0   50
sint8-1   127FF   7F
uint1665535FFFF
sint16220016
uint32102400000400
sint321234500003039
uint64112593750000000000ABCDEF
sint64-9876543210FFFFFFFDB34FE916
float-1.25BFA00000
double3e99   5.05495F202F9E5B763   4014000000000000
text<![CDATA["Hello there!"]]>0048 0065 006C 006C 006F 0020 0074 0068 0065 0072 0065 0021

Notes:

 


When exporting text (values with code="std" and element names) to XML, the characters ", &, ', <, >, and ^ shall be encoded as follows:

"^0022
&^0026
'^0027
<^003C
>^003E
^^005E

The four characters after the ^ represent the hexadecimal value of the given character in UTF-16.

All characters below 20 or above 7E may be encoded using the same format.

 

Example:

Plain text:The Greek "alphabet" begins with the letters αβγ.
Encoded text:The Greek ^0022alphabet^0022 begins with the letters ^03B1^03B2^03B3.

 


www.rclsoftware.org.uk/dendros


 

Valid HTML 4.01