TOC PREV NEXT INDEX


Generated XER Decode Functions


NOTE: XER is maintained as a legacy XML format for ASN.1. New applications should consider using XML as described in the next section instead of XER. XML is more closely aligned with W3C standard XML and XML schema.


The code generated to decode XML messages is different than that of the other encoding rules. This is because off-the-shelf 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://www.expat.org). 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.



Objective Systems, Inc.

55 Dowlin Forge Road
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX