Introducing JiBX
JiBX is one of many tools used for converting between Java data structures and XML documents (see Resources). What sets JiBX apart from the others are performance and flexibility features. JiBX performance consistently measures at the top end of the range, surpassing that of other common tools (such as JAXB 2.0) by a factor or two or more. JiBX is also more flexible than almost all other Java-XML tools, using binding definitions to decouple the Java structure from the XML representation so that each can be changed independently of the other.
With the 1.2 release, JiBX adds major features supporting XML schema definitions. You can use tools included in the JiBX release to generate a schema definition matching your Java code or to generate Java code matching your schema definition. Either way, you also get a binding definition that lets you use JiBX to convert between the Java code and XML documents matching the schema definition. In this tutorial, you'll see how to apply the second type of generation: going from a schema definition to Java code.
Installing JiBX
You'll need to install JiBX before proceeding with this tutorial. Download the latest 1.2.x distribution ZIP and expand it to a convenient location on your system. You'll end up with a directory named jibx, which contains all the JiBX JARs, documentation, examples, and even the source code.
Installing the tutorial code
Now download the tutorial sample code, also provided as a
ZIP file. The easiest way to install it on your system is to expand the ZIP into the
root directory of your JiBX distribution (or on Windows®, copy the dwcode2 directory from inside the ZIP file to the root directory of your JiBX distribution). This should create a dwcode2 subdirectory in the jibx directory, with the example files (including build.xml, custom.xml, and others) inside that dwcode2 subdirectory.
The sample code includes an Ant build file to automate running the JiBX tools and
handle the other steps involved in the examples. If you install the sample code
directly into the JiBX installation directory, the build can access the JiBX JARs
without any additional configuration. If you install the sample code elsewhere, you can still use the Ant build. In this case, you just need to edit the build.properties file inside the sample code directory and change the value of the jibx-home property to the path of your JiBX installation.
|