InstallationTo install JiBX, just download the distribution zip file and unpack it. This will create a jibx directory that contains the distribution files, including a complete copy of this documentation. The readme.html file in the unpacked root directory gives more information and links to some included demonstration code, and to the local copy of this documentation. If you're using Maven, you can use the JiBX repository at http://jibx.sourceforge.net/maven/ to get a specific version of the distribution jar files (as jibx-bind-1.x.x.jar, jibx-run-1.x.x.jar, etc.). There's also a Maven2 plugin available for JiBX. Binding definitionsTo use JiBX, you'll need to first create a binding definition that describes how your XML documents are connected to your Java objects. Here's a simple example just to give you a feeling for how this works: Figure 1. Simple binding exampleIn this example I've got an XML document with a <customer> root element
that I want to bind to a JiBX's binding capabilities go far beyond what's shown by this simple example. On the
Java side, you can use fields of any access type (including If you're starting from existing Java code you may find the Generator Tools subproject useful. This includes a tool which will generate a default binding for a set of Java classes (and a separate tool to generate an XML schema definition from a binding definition and the referenced Java classes). Similarly, if you're starting from an XML schema definition you may find the Xsd2Jibx subproject useful. This provides a tool to generate a set of Java classes and a corresponding binding definition from a schema. These subprojects can help a lot in getting started, but you should still take the time to understand how bindings work before you go too far with JiBX. Using JiBXOnce you've got a binding definition for your document format you're ready to begin using JiBX. To do this, you first compile your application classes as normal, then run the JiBX Binding Compiler. The binding compiler converts your binding definition into actual code in the form of binding methods that it adds to your application class files (you can also run the binding compiler at runtime, to modify your classes before they're loaded into the JVM). The methods added by the binding compiler are then used by the JiBX Runtime to actually marshal and unmarshal your Java classes to and from XML. Starter projectThe JiBX distribution includes an example starter project, with an Ant build.xml script for compiling, binding, and running the project code. This is found in the starter directory off the installation root. See the index.html page in this directory for details. DetailsThat's the summary. Here are the links for the details of these steps, along with information on some useful tools included in the distribution: |