Data Segment - shaunturner84/transmute GitHub Wiki

This segment of the file details out the actual data structure. This involves a parent/child relationship of a number of elements.

Table of Contents

Types of element

There are numerous types of element:

Container Element

A container can have multiple child elements, it is the only element type capable of holding other elements. The trade off however is that it cannot contain any values

Name Type Description
Element Type BYTE For a container element this is always 0
Tag ID) UINT16 The index of the tag in the header section
Number of child elements UINT16 The number of child elements
Child DATAELEMENT A child
Child DATAELEMENT A child
... ... ...

Attribute Element

This represents what would be classed as an attribute in XML, there is a limit of 255 characters for each attribute.

Name Type Description
ELEMENT_TYPE BYTE For an attribute element this is always 1
TAG_ID UINT16 The index of the tag in the header section
VALUE_LENGTH BYTE The length of the value string
VALUE_ACTUAL STRING The length of the value string

Text Element

This represents a value / text field. The value length is limited to 32767 characters

Name Type Description
ELEMENT_TYPE BYTE For a text element this is always 2
TAG_ID UINT16 The index of the tag in the header section
VALUE_LENGTH UINT16 The length of the value string
VALUE_ACTUAL STRING The length of the value string

Example

In XML terms

<Customer name="John Smith">
  <Order id="ord-0123">
    <Product id="prod-456">Scooter</product>
    <Product id="prod-789">Bicycle</product>
  </order>
</customer>

Stripping out the excess whitespace would leave 149 bytes of data.

In JSON

{ "Customer": 
  { name = "John Smith",
    "Order": 
    {
      "id" : "ord-0123",
      product :
      {
        {         
           "id" : "prod-456",
           "value" : "Scooter"
        },
        {        
           "id" : "prod-789",
           "value" : "Bicycle"
        }
      }
    }
  }
}

Stripping out the excess whitespace would leave 143 bytes of data.

In transmute

This would be represented as:

0 1 0 0004 0 8 Customer 0 4 name 0 4 name 0 5 Order 0 2 id 
0 00 02 1 01 8 John Smith 0 02 03 1 03 8 ord-0123 0 04 02 1 03 8 prod-456 2 07 Scooter 0 04 02 1 03 8 prod-789 2 07 Bicycle

This is a 131 byte binary made up of:

  • 0 (Document Source = JSON)
  • 1 (Encoding = UTF8)
  • 0 (Number of namespaces - empty as no namespace defined)
  • 0004 (Number of tags)
  • 0 (Namespace ID)
  • 8 (length of tag name)
  • Customer (tag name)
  • 0 (Namespace ID)
  • 4 (length of tag name)
  • name (tag name)
  • 0 (Namespace ID)
  • 4 (length of tag name)
  • name (tag name)
  • 0 (Namespace ID)
  • 5 (length of tag name)
  • Order (tag name)
  • 0 (Namespace ID)
  • 2 (length of tag name)
  • id (tag name)
  • 0 (Type of element = Container)
  • 00 (tag id of "Customer")
  • 02 (Number of child elements)
    • 1 (Type of element = attribute)
    • 01 (tag id of "name")
    • 8 (length of the value string)
    • John Smith (the value string)
    • 0 (Type of element = container)
    • 02 (tag id of "Order" tag)
    • 03 (Number of child elements)
      • 1 (type of element = attribute)
      • 03 (id of "id" tag)
      • 8 (length of the value string)
      • ord-0123
        • 0 (type of element = container)
        • 04 (tag id of "Product" tag)
        • 02 (Number of child elements)
          • 1 (type of element = attribute)
          • 03 (tag id of "id" tag)
          • 8 (length of the value string)
          • prod-456
          • 2 (type of element = text)
          • 07 length of the text string
          • Scooter
        • 0 (type of element = container)
        • 04 (tag id of "Product" tag)
        • 02 (Number of child elements)
          • 1 (type of element = attribute)
          • 03 (tag id of "id" tag)
          • 8 (length of the value string)
          • prod-789
          • 2 (type of element = text)
          • 07 length of the text string
          • Bicycle
⚠️ **GitHub.com Fallback** ⚠️