This example explain how to apply X-O lite XML serialization/deserialization to a simple java object model.
This example models a company. It's just a data-oriented model where you can store a Company, it's address the list of employees and contractors working in the company and their private address. It's a very simplified model but it already demonstrates two object behaviors:

This model is mapped to a XML like:
<?xml version="1.0"?>
<company xmlns="xo-lite.sf.net/examples/company">
<name>Test Company 2</name>
<address>
<street>Grand rue</street>
<number>123</number>
<town>Brussels</town>
<country>Belgium</country>
</address>
<workers>
<employee id="E1">
<name>
<firstName>Bill</firstName>
<lastName>Foo</lastName>
</name>
<privateAddress>
<street>Plattestraat</street>
<number>45</number>
<town>Zotteghem</town>
<country>Belgium</country>
</privateAddress>
<department>ICT</department>
</employee>
<contractor id="C1">
<name>
<firstName>Joe</firstName>
<lastName>Bar</lastName>
</name>
<privateAddress>
<street>Dr�ve du bois</street>
<number>6</number>
<town>Waterloo</town>
<country>Belgium</country>
</privateAddress>
<companyName>ICT pro S.A.</companyName>
</contractor>
(... other employees or contractors ...)
</workers>
</company>This is a simple XML but it already have some particularities that can make it difficult to bind to java objects:
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/company
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:
Mapping this model to XML is a very regular case for X-O lite. There is nothing special in the model objects XMLSerializable implementation
You can just note the boolean passed to the Address object in it's constructor so that it can know if it is used as a company address or as the private address of a person (and hence choose the correct tag when serialized).
For this implementation, as an example, we've made the choice to validate the input XML in the parsing code (although it is also checked by the internal parser via the XML schema). This way you can turn of the parser schema validation and still have a 'minimum' validation. But, it requires some extra code.
Though this simple project is not the best target for X-O lite applicability (because objects are merely data holders) you can already see the benefits of X-O lite Object Oriented approach.
This example also demonstrates that X-O lite plays well with java XML APIs.