This example demonstrates how extend the recursive model example and benefit of the X-O lite serialization/deserialization inheritance.
Extension, here is taken in a strict Object-Oriented sense: it means that you want to add behaviour/objects to a pre-existing set of objects (mapped to XML) but without changing anything to the existing classes, namespaces or XML schemas. You just want to add new classes, namespaces or XML schemas.
It's exactly like if you want to extend, for example, the java Swing library by adding your own components. You want to be able to do it without changing swing code, without changing the swing 'namespace' (in java the namespace is usually the package, it means you don't want to be forced to put your own classes in the javax.swing package) or any configuration in the installed JRE. If it were the case, nobody would call Swing an 'open' or 'extensible' library. To extend Swing you just have to add your own components (extending swing components) by adding your own classes in your own package and they will combine seamlessly with the standard swing component.
This example will do the same for the previous recursive model example. It will add a "Xor" boolean operation without modifying any file to this previous example. Every new class will be added in a new java package and every new XML definition will be added in a new XML schema (with a new namespace).
The purpose of this example is to demonstrate that X-O lite mapping doesn't prevent you to build extensible frameworks. It's easy to define 'extension points' in java and XML that allows other project to customize your framework by extending it the Object-Oriented way.
The complete source code of this example is located in the:
xo-lite-1.0/src-projects/xo-lite-examples/src/main/java/net/sf/xolite/extension/xolite
directory inside the xo-lite-1.0-all.zip or xo-lite-1.0-all.tgz distribution archive.
To build and run all the examples:
Allowing true Object-Oriented extension of models mapped to XML is easy with X-O lite.
The XML-to-object mapping doesn't prevent you to benefit from usual Object-Oriented extension mechanism. In this example, the XorExpression class implementation is really simple because it benefits of (inherit from) all the parent class (the CompositeExpression) data and behaviour.