Parsing/Serializing XML with XO-lite
XO-lite is a thin layer above the Simple API for XML (SAX). It allows using SAX in a Object Oriented world.
Usual solutions defer all the parsing (and the document knowledge) to a 'Handler' class which will automatically fill-in the parsed objects (and, hence, access their internal representation) through some predefined interface or through introspection. The method proposed here will let each object parse it's own data and put it in it's own variables (with helpers reducing this code to the minimum). The parsing of the whole document is achieved by moving the parse control to each java object during the SAX event notification.
Java to XML serialization is also analyzed with emphasis on the symmetry between serialization and deserialization. In a symmetric world, you can build a java object tree from a sequence of SAX events or generate the same sequence of SAX events from the java object tree.
The result is XML-serializable objects that can be used as java serializable objects. You can combine those objects as you wish, the resulting object tree can also be serialized (back and forth) to XML without any extra work required.
Key benefits:
* Very simple solution applicable for complex real-life XML parsing though it only requires few support classes/interfaces.
* Objects with private variables. Objects have just the knowledge of the data (and they associated XML tags) they own.
* Objects have just to implement a single interface with 3 method to be XML-serializable.
* Same objects can be re-used to be part of many XML document (or be re-used in the same document).

