Flexibility

The mapping JiBX applies in converting between your classes and XML is specified by a binding definition. The binding definition lets you control such basic details as whether a particular simple property of a class (such as a primitive value, or a String) is mapped to an element or an attribute in the XML document, and the name used for that element or attribute. You can also tell JiBX how to access that property - either as a field (which can have any access qualifier, including private) or as a JavaBean-style property with get and set methods. You can even specify values as optional, and define serializers or deserializers for converting simple values to and from text.

JiBX goes beyond this simple form of mapping, though. Other data binding frameworks generally force each XML element with complex content (attributes, or child elements) to be mapped to and from a distinct object, so that your object structure directly matches the layout of your XML documents. With JiBX you can be more flexible - child elements can be defined using a subset of the properties of an object, and properties of a referenced object can be included directly as simple elements or attributes of the current element. This lets you make many types of changes to either your class structure or your XML document structure without needing to change the other to match.

There are limits to the flexibility provided by JiBX, but by giving you the ability to adapt to changes it helps insulate both sides of the Java-XML binding from changes in the other side. This is especially useful for new projects where XML document interchange formats may need to be defined early on, while the application code is still undergoing development. The binding definition allows you to refactor your code without effecting other components using the same XML documents. For more details, see the Structure mapping discussion in the Binding Tutorial.