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:
|
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 element | Description |
| dendros | An XML representation of a Dendros document. |
| element | An XML representation of a Dendros element. |
| value | An XML representation of a Dendros value. |
These XML attributes must be used with the described XML elements:
| XML element | XML attribute | Description | ||||||||||||||||||||||||||
| dendros | version | The Dendros version of the XML encoded document. | ||||||||||||||||||||||||||
| element | name | The Dendros element's name. | ||||||||||||||||||||||||||
| value | type | Specifies the data type, corresponding to the value_marker:
| ||||||||||||||||||||||||||
| value | code | hex = 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" |
| bool | false true | 00 01 |
| uint8 | 160 80 | A0 50 |
| sint8 | -1 127 | FF 7F |
| uint16 | 65535 | FFFF |
| sint16 | 22 | 0016 |
| uint32 | 1024 | 00000400 |
| sint32 | 12345 | 00003039 |
| uint64 | 11259375 | 0000000000ABCDEF |
| sint64 | -9876543210 | FFFFFFFDB34FE916 |
| float | -1.25 | BFA00000 |
| double | 3e99 5.0 | 5495F202F9E5B763 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