Optimizing your JiBX Schema Library Project

To increase the usefulness of your schema library, you may want to optimize it.

For a simple, well designed schema, our tools do an excellent job of creating java bindings.

As schema get more complicated, you may want to change the way code is generated or actually modify the java code and the JiBX bindings to make them more usable. This is where JiBX shines. The JiBX tools can optimize the generation and binding of java code in many ways.

For example many of the definitions in the wsdl 1.1 spec begin with a 't':
<xs:complexType name="tBinding">
which results in a java class called TBinding. Wouldn't it be better to call the java class Binding?

Completely Optimize your library

For a example of thorough optimization, see the opentravel.org schema. This schema has been optimized in several ways.

The opentravel schema are huge, almost 300 schema definitions for nearly 20 different business segments all in one namespace. A huge java library would be terribly inefficient. Now, the library is broken into 21 OSGi bundles. The complex dependencies are managed automatically.

Use xslt to fix your schema

If you are using a schema that you can't change, do an xsl transformation before processing it by JiBX. A great example is the webservicex schema. The schema defininitions are embedded in wsdl files. A simple xslt file extracts the schema definition so we can build the java binding. Even if the schema owner changes their schema definition, our project will still build correctly.

Customize your binding definition

If you would like to add methods that would be useful in your java class, JiBX allows this.
You can take the pre-built binding definition and customize it for use in your java class.
For example, if you had a schema that supplied a file's location and name, wouldn't it be nice to have a java method that returned a File object:
public File getFile() {
  return new File(getLocation() + File.separator + getName());
}