Customising a Parser Plug-in

The parser plug-ins supplied with the XML framework can be customised to suit the structure of a particular document. This section explains how to customise the WBXML parser.

Introduction

To parse a WBXML document with a DTD which has not previously been implemented for the Symbian platform XML framework, add a new string table representing the DTD.

Parsers use string dictionaries to convert a file of text strings into a string pool of RString objects. The strings within the dictionary are linked to the String Table statically at compile time. A string table is a text file having a .st extension. It contains the name of C++ enumeration constants paired with the strings they refer to. Each pair occupies a line of text and its two elements are separated by white space, as shown in the following example:

stringtable Wml1_1CodePage00TagTable
EA          a
EAnchor     anchor
EAccess     access

The simplest use of a string table arises when WBXML is used as a method of compressing generic XML. In such scenario, create a single .st file for all frequently used strings. In the example scenario, the task is slightly complex because a specific XML application which conforms to a DTD is being parsed. A DTD specifies elements along with attributes. Create three separate .st files as to place these attribute values, as shown in the above example. It is the file containing attribute values which are required. The left hand column of an attribute value string table must be exactly the same as the left hand column of the corresponding attribute string table. That is, it must list the same constant names and list them in the same order. The right hand column of an attribute value table contains the values defined for the attributes. However, it may be that no value is defined for some attributes. In such scenario, the attribute value table contains a line consisting only of the constant name, followed not by white space but by the end of the line.

The following two examples show a fragment of an attribute string table and the corresponding attribute value string table:

EAcceptcharset                  accept-charset
EAlign1                         align
EAlign2                         align
EAlign3                         align
EAcceptcharset
EAlign1
EAlign2                         bottom
EAlign3                         top

In this example, the accept-charset attribute has no value defined for it. Hence, the constant name EAcceptCharset is paired with nothing in the attribute value table. The attribute 'align' may take no value or the values 'bottom' and 'top'. Therefore, the first table pairs it with three different constant names and the second table pairs the constant names with nothing, 'bottom' and 'top'.

Procedure

  1. Implement a new string table.

  2. Convert the string table to the code.

    Convert the string tables to C++ by invoking the conversion tool from the build files when you compile your parser. The conversion tool can be found in ...\epoc32\tools\. For more information about the tool, refer to String pools.