Skip to content
gschwind edited this page May 6, 2011 · 16 revisions

BML description and specification.

BML is Binary Markup Language. Like XML, BML is an (informatics) tree. Each node of tree have an identifier, children and data. Sheet of the tree are nodes without children.

Spec. (this spec is a DRAFT)

BML file header.

A BML file start by a header, bml_header, of 4 bytes which correspond with the following C definition :

char bml_signature[4] = { 'B', 'M', 'L', 0 };

Nodes

Each node:

  • an identifier (id): an unsigned integer up to 128 bits,
  • data: arbitrary binary data limited to 2^128-1 bytes,
  • children: unlimited list of node.

Nodes have the following layout:

[node] = [node_header][data][node_list]

The [node_header] describe the node content, [data] are arbitrary data, and [node_list] is the list of children nodes.

Node header

The [node_header] have the following layout:

[node_header] = [compaction_byte][id][data_size]

The [compaction_byte] is one byte. This byte contents the length in byte of the [id] and the length in byte of the [data_size]. The length of [id] can be 1 to 16, and the length of [data_size] can be from 0 to 16. The coding of [compaction_byte] are the following:

unsigned int id_length = ([compaction_byte]>>4)&0x0f;

unsigned int data_size_length = ([compaction_byte]>>0)&0x0f;

The [id] is unsigned integer. id is coded in little-endian integer and compacted, is length in byte is provided by [compaction_byte] as explain before.

The [data_size] is unsigned integer. data_size is coded in little-endian integer and compacted, is length in byte is provided by [compaction_byte] as explain before.

In this format the size of [node_header] is from 2 bytes to 33 bytes.

Data

Data are arbitrary binary file. the size of data is provided by the header in byte.

Children

Children is a list of node which are sub node to this node. Child node have the same layout of node. the list of child node end by a special node, call empty node. empty node have is the [compaction_byte] set to 0. the empty node cannot be inserted into list of node, this node always denote the end of node list.

Root node

The BML header is always followed by the root node, this node have an id set to 0.

Remarks = root node have id 0 but this id can be used for other nodes.