next up previous
Next: Conclusions Up: Design of a Pull Previous: Implementing XML Pull Parser


Supporting multiple implementations of XPP2 API

XPP2 consists of two distinctive APIs and a default implementation. The XPP2 API was designed to allow plugging different implementations in such way that user code does not have to change at all. This is achieved with use of XmlPullParserFactory that is responsible for creation of XmlPullParser instances. The factory to be used is parametrized based on existence of special file with factory name on CLASSPATH or name of factory class passed to XmlPullParserFactory.newInstance() method. We do not use java System properties by default as they are not available on J2ME platform, however are easy to use with this code:


As an example of such additional implementation of XPP2 API we are providing implementation that uses Xerces 2 XNI pull model. Therefore the user can use XPP2 either with fast default implementation or fully validating Xerces2 engine.

SAX2 driver for XPP2

As it was mentioned earlier it is desirable and clearly feasible to translate pull events into SAX2 push callbacks. As part of XPP2 we are providing utility class that can take XPP2 API (implemented by default implementation or Xerces 2 or any other) and transform it into SAX2 XmlReader.

C++ version

We have also written a C++ version of XPP1 (Xml Pull Parser version 1). As of now, the C++ version of XPP2 is not available however differences between XPP1 and XPP2 are not that big for just XmlPullParser interface. C++ version has some additional limitations such as it does not support UNICODE fully (it is possible to compile it with chat or wchar_t support) and user needs to assume that input is encoded as UTF8 (or when compiled with wchar_t assume UTF16). Additionally XPP1/C++ does not support streaming and requires all input to be passed in one array.

next up previous
Next: Conclusions Up: Design of a Pull Previous: Implementing XML Pull Parser
Aleksander Andrzej Slominski