Before you start
JiBX is a tool for binding XML data to Java objects. JiBX data binding has long been known as the fastest and most flexible approach for binding Java code to XML. But the complexity of its binding definitions and its limited support for increasingly widely used XML schema definitions have frustrated users at times. Fortunately, the 1.2 version of JiBX goes a long way toward eliminating these issues. In this tutorial, you'll learn about using the new features of JiBX 1.2 to generate XML schema definitions easily from existing Java code and to read and write XML documents matching the generated schema definitions — all without needing to get into the details of JiBX binding definitions. Part 2 covers the flip side of starting from XML schema definitions and generating Java code.
This tutorial guides you through the process of using JiBX to generate XML schema definitions from Java code. You'll first see how to start with a simple Java data model and generate a default schema matching that model. From that base, you'll learn how you can easily apply a range of customizations to control the actual values used from your Java classes and how they're accessed, whether they are required or optional, names and namespaces used in the XML, and even the generated schema definition's structure. Along the way, you'll see how JiBX adds value to your generated schemas by leveraging your investment in Javadocs to document the schema definition automatically. After reading this tutorial and working through the supplied examples, you will be able to use JiBX to generate quality XML schema definitions from your own Java data-structure classes.
To understand this tutorial, you should have at least a basic knowledge of both Java code and XML. You don't need a detailed understanding of XML schema definitions, but some familiarity with schema will help you understand the examples better.
To run the examples, you need to install:
- A recent version of the Apache Ant build tool.
JiBX download and installation instructions are included in the tutorial.