Pull-Parser Based Decode Methods

An XML pull-parser works by allowing a user to “pull” selected events from an XML stream as it is parsed. This differs from the SAX model which is sometimes referred to as a “push” parser because event callbacks are executed (pushed) as the stream is parsed. The pull model offers significant advantages for a data binding type application because it is easier to maintain state between operations. This results in less required code to do the decoding which in turn leads to improved performance. It is also conceptually easier to understand because the function call model more closely approximates the model used for encoding.

Generated C++ Method

Format for XSD Types Implementations of C++ pull-parser based decode methods are written to a .cpp file with a name of the following format:

        <xsdFileName>Dec.cpp

where <xsdFileName> is the base name of the XSD file being parsed. For example, if code is being generated for file x.xsd, decode methods for each type and global element defined in the specification will be written to xDec.cpp. If the file being processed is a WSDL file, the suffix would be WSDLDec.cpp (for example, x.wsdl would produce xWSDLDec.cpp).

The format of the name of each generated XML decode method is decodeXML. The calling sequence is as follows:

        stat = <object>.decodeXML (OSCTXT* pctxt);

In this definition, <object> denotes an object instance of the generated class.

The pctxt argument is the underlying context to the decode message buffer or stream object. It can be obtained by calling the getCtxtPtr method.

The function result variable stat returns the status of the decode operation. Status code 0 (zero) indicates the function was successful. A negative value indicates decoding failed. Return status values are defined in the rtxErrCodes.h include file. The error text and a stack trace can be displayed using the rtxErrPrint function.

A key difference between SAX-based functions and pull-parser based is that a decode function is not generated for all types in the SAX case. That is because of the overhead invlolved in setting up the SAX parser to decode simple types. Most simple types are decoded inline as part of more complex types. This is an example of a case where the pull-parser model more closely follows the encode model.

Generated C++ Method Format for XSD Global Elements

The generated C++ decode method for global elements is the same as for the SAX case described below. The decode or decodeFrom that are added to the generated control class are the entry points for decoding complete XML documents in either the pull-parser or SAX case.

Generated C++ Method Format for Factory Class

The generated C++ decode method for factory class is similar to that for global elements. The decode method is the entry points for decoding complete XML documents.

Generated C++ Method Format for WSDL Operations

The generated C++ decode method for global elements is the same as for the SAX case described below. The decode or decodeFrom that are added to the generated control class are the entry points for decoding complete XML documents in either the pull-parser or SAX case.