There are three ways of using the WBXML Library:
File convertion Tools : The xml2wbxml and wbxml2xml programs.
Buffer convertion Library : The libwbxml2_conv library.
Low level WBXML Parser and Encoder : The libwbxml2 library.
This are the high level components of the WBXML Library. This tools need the libwbxml2_conv, libwbxml2 and  libraries.
There are two Convertion Tools:
xml2wbxml tool - Convert an XML File to a WBXML File.
wbxml2xml tool - Convert a WBXML File to an XML File.
This is the library version of the Convertion Tools. Use this library if you need to convert
XML and WBXML buffers inside your own Program. This library needs to link with the libwbxml2 and  libraries.
There are two Convertion Functions:
xml2wbxml function - Convert an XML Buffer to a WBXML Buffer.
wbxml2xml function - Convert a WBXML Buffer to an XML Buffer.
This is the low-level WBXML Library component. It uses an intermediary WBXMLTree structure to represent a WBXML Document,
and it contains a WBXML Parser and a WBXML Encoder. Use this library if you have to deal with an in-memory representation
of the WBXML Document, or if you want to parse a WBXML Document into your own internal structures. This is a standalone library.
The main modules of the libwbxml2 library:
wbxml_buffers
This contains functions to manipulate generic Buffers (WBXMLBuffer). This buffers are used in the 'wbxml_elt' module
to store Literal Tags and Literal Attribute Names.
wbxml_tables
This module contains all the WBXML Tables. It defines too the structures:
WBXMLTagEntry - A WBXML Tag Entry in WBXML Language Table
WBXMLAttrEntry - A WBXML Attribute Entry in WBXML Language Table
WBXMLLangEntry - A full WBXML Language Table
wbxml_elt
This module defines the WBXML Elements used in the WBXML Tree structure:
WBXMLTag - A WBXML Tag
WBXMLAttributeName - A WBXML Attribute Name
WBXMLAttribute - A WBXML Attribute
typedef struct WBXMLTag_s {
WBXMLValueType type;                    /* Tag Type (Token or Literal) */
union {
const WBXMLTagEntry   *token;       /* Token Tag (MUST be const structure, ie from wbxml_tables.c) */
WBXMLBuffer           *literal;     /* Literal Tag (MUST be dynamically allocated WBXMLBuffer) */
} u;
} WBXMLTag;
The WBXMLTag type can be either:
WBXML_VALUE_TOKEN - In this case, the Tag Name is a token, a pointer to a WBXMLTagEntry structure.
WBXML_VALUE_LITERAL - In this case, the Tag Name is a literal, a pointer to a WBXMLBuffer structure.
typedef struct WBXMLAttributeName_s {
WBXMLValueType  type;               /* Attribute Name Type (Token or Literal) */
union {
const WBXMLAttrEntry *token;    /* Token Attribute Name (MUST be const structure, ie from wbxml_tables.c) */
WBXMLBuffer          *literal;  /* Literal Attribute Name (MUST be dynamically allocated WBXMLBuffer) */
} u;
} WBXMLAttributeName;
The WBXMLAttributeName type can be either:
WBXML_VALUE_TOKEN - In this case, the Attribute Name is a token, a pointer to a WBXMLAttrEntry structure.
WBXML_VALUE_LITERAL - In this case, the Tag Name is a literal, a pointer to a WBXMLBuffer structure.
typedef struct WBXMLAttribute_s {
WBXMLAttributeName  *name;  /* Attribute Name */
WBXMLBuffer *value;         /* Full Attribute Value */
} WBXMLAttribute;
The WBXMLAttribute contains:
An Attribute Name : A WBXMLAttributeName structure.
An Attribute Value : A WBXMLBuffer structure.
The 'value' part of an WBXMLAttribute contain the FULL attribute value.
For example, with the attribute: url="http://127.0.0.1/"
if the 'name' part is this:
- name->u.token->wbxmlCodePage: 0x00
- name->u.token->wbxmlToken : 0x4b
- name->u.token->xmlName : "url"
- name->u.token->xmlValue: "http://"
then, 'value' is still: "http://127.0.0.1/"
Of course (in this example) it should be better to have the wbxmlToken 0x4a ("url" / NULL). So you mustn't take into
account the 'xmlValue' field for 'name' to get the Attribute Value of this Attribute.
wbxml_tree
This module define a WBXML Tree. This is the main in-memory representation of a WBXML Document, used by
the WBXML Parser and the WBXML Encoder.
A WBXML Tree is composed of WBXML Nodes which can be: an Element Node, a Text Node or a PI Node.
typedef enum WBXMLTreeNodeType_e
{
WBXML_TREE_ELEMENT_NODE = 0, /* Element Node */
WBXML_TREE_TEXT_NODE,        /* Text Node */
WBXML_TREE_PI_NODE,          /* PI Node */
} WBXMLTreeNodeType;
A WBXMLTreeAttribute is a structure that permits to chain several WBXMLAttribute structures into a List.
typedef struct WBXMLTreeAttribute_s
{
WBXMLAttribute  *attr;              /* Attribute */
struct WBXMLTreeAttribute_s  *next; /* Next attribute */
} WBXMLTreeAttribute;
A WBXML Tree is composed of WBXML Nodes.
typedef struct WBXMLTreeNode_s
{
WBXMLTreeNodeType   type;       /* Node Type */
WBXMLTag            *name;      /* Node Name (if type is 'WBXML_TREE_ELEMENT_NODE') */
WBXMLTreeAttribute  *attrs;     /* Node Attributes (if type is 'WBXML_TREE_ELEMENT_NODE') */
WBXMLBuffer         *content;   /* Node Content (if  type is 'WBXML_TREE_TEXT_NODE')  */
struct WBXMLTreeNode_s  *parent;    /* Parent Node */
struct WBXMLTreeNode_s  *children;  /* Children Node */
struct WBXMLTreeNode_s  *next;      /* Next sibling Node */
struct WBXMLTreeNode_s  *prev;      /* Previous sibling Node */
} WBXMLTreeNode;
Finally, a WBXML Tree defines a WBXM Language and a root WBXML Node.
typedef struct WBXMLTree_s
{
const WBXMLLangEntry  *lang; /* Language Table */
WBXMLTreeNode   *root;       /* Root Element */
} WBXMLTree;
wbxml_encoder
The WBXML Encoder is used to encode a WBXML Tree into:
A WBXML Document : wbxml_encoder_encode_to_wbxml()
An XML Document : wbxml_encoder_encode_to_xml()
Cf. the Reference Chapter for more informations about this functions.
wbxml_parser
The WBXML Parser can be used in two ways:
Parse a WBXML Document into a WBXML Tree : wbxml_parser_parse_to_tree()
Parse a WBXML Document into your own internal structures, by implementing your own Parser Callbacks : wbxml_parser_parse()
Cf. the Reference Chapter for more informations about this functions.
