Generated XER Decode Functions (Old Style - Deprecated)

Note

As noted in the Overiew, the style of generated code that is discussed here is now deprecated. To upgrade to the new style, see the section below for some upgrade tips. The old-style XER decode functions can still be generated by specifying the -xer -compat 649 (or lower) switches on the command line. This ability may be removed in some future version of ASN1C, so you are encouraged to upgrade to the new style.

The code generated to decode XML messages is different than that of the other encoding rules. This is because off-theshelf XML parser software is used to parse the XML documents to be decoded. This software contains a common interface known as the Simple API for XML (or SAX) that is a de-facto standard that is supported by most parsers. ASN1C generates an implementation of the content handler interface defined by this standard. This implementation receives the parsed XML data and uses it to populate the structures generated by the compiler.

The default XML parser used is the EXPAT parser (http://expat.sourceforge.net). This is a lightweight, open-source parser that was implemented in C. The C++ SAX interface was added by adapting the headers of the Apache XERCES C++ XML Parser (http://xml.apache.org) to work with the underlying C code. These headers were used to build a common C++ SAX interface across different vendor’s SAX interfaces (unlike Java, these interfaces are not all the same). The ASN1C XER SAX C and C++ libraries come with the EXPAT parser as the default parser and also include plug-in interfaces that allow the code to work with the Microsoft XML parser (MSXML), The GNOME libxml2 parser, and the XERCES XML parser. Interfacing to other parsers only requires building an abstraction layer to map the common interface to the vendor’s interface.

A diagram showing the components used in the XML decode process is as follows:

Step 1: Generate code

Step 2: Build Application

ASN1C generates code to implement the following methods defined in the SAX content handler interface:

   startElement

   characters

   endElement

The interface defines other methods that can be implemented as well, but these are sufficient to decode XER encoded data.