Generating Java code and binding definitions from XML schema definitions is easy with JiBX. The CodeGen tool, added in the 1.2 release, allows you to use both automatic and customized generation for your XML schemas. It provides some very useful features for generating clean code, including:
If you compare the data models generated by CodeGen with other Java code generation
from schema tools you'll see some significant differences, especially when it comes to
schema features like xs:choice and xs:attributeGroup/xs:group. Most other Java code
generation tools basically ignore xs:choice and leave it to the developer to understand
that they can only set one of the alternatives. CodeGen optionally supports this approach
(using the choice-handling="stateless"
customization), but by default generates code which allows only one of the choices to be
set at a time. CodeGen also differs from most other tools of this type in that it
generates separate classes for xs:attributeGroup and xs:group schema constructs which
are used in more than one place, rather than just inlining the values at each reference.
This allows cleaner handling of these groups of values in your code, since they typically
represent a collection of related values which will be used together.
For an in-depth look at using CodeGen, see the JiBX 1.2, Part 2: XML schema to Java code tutorial on the IBM developerWorks site. You can also look over the CodeGen examples included in the distribution, which are discussed in this section of the documentation.
This section of the documentation currently covers only CodeGen. In the future web services code generation directly from WSDL will be supported, and this section will be expanded to include information on the tool used for that purpose.