Another Conversion Example
Listing 3 (XML) and Listing 4 (WBXML) contain a second conversion example. There is one difference between this example and the first one, this example shows the WBXML for a SyncML file. Unlike the WML file for the first example, there's no DTD containing a WBXML encoding table. Therefore, the example uses string table references for the tag names. To do this, use the 0x04 global token to refer to the string table. To each byte, add 0x40, 0x80, or 0xC0 to this global token for attributes and content as discussed in the first example. Following the string table reference byte you'll find an offset byte that tells how many bytes to skip from start of the string table before starting to read. For example, suppose you have the following string table:
't' 'a' 'g' '1' 'NULL' 't' 'a' 'g' '2''NULL' 't' 'a' 'g' '3''NULL'
If you write 0x04 0x05, which specifies an element name, then you're referring to tag2. The 0x04 means jump to the string table and 0x05 means read from fifth byte of the string table up to a NULL character.
In Part II of this article, you'll see how to use WBXML on the server.