JiBX: Starting from Schema

# JiBX: Starting from Schema |

JiBX Basics Overview Getting Started Binding Compiler Binding on Load Runtime Extras Building JiBX Contributing License News and Status Support FAQ Mailing Lists Bugs User Comments Sponsors Start from Code Start from Code BindGen Example Code Example 1 Example 2 Example 3 Example 4 Customizations Reference SchemaGen Jibx2Wsdl Examples Customizations Start from Schema Start from Schema CodeGen Example Code Example 1 Example 2 Example 3 Customizations Reference Binding Definition Binding Tutorial A basic binding Binding extras Structure mapping Collections and arrays Using mappings Advanced binding Method hooks Custom code Precompiled Bindings Definition details Definition contexts Conversions XML summary <binding> element <include> element <format> element <namespace> element <mapping> element <value> element <structure> element <collection> element Attribute groups Usage API Runtime JavaDocs Subprojects Eclipse Plug-in Introduction Install Usage Axis2 Usage | ### Starting from schema 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: Import schema documentation as JavaDocs Support for both untyped and typed (Java 5) collection classes Support for both custom typesafe enumerations and Java 5 enums Advanced schema analysis to keep the generated data model as simple as possible Customization support to easily prune unnecessary or unused schema components from the data model 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. CodeGen does have some limitations, which are planned to be addressed by continued development of the JiBX 1.2.x codebase. Here are the main ones: xs:union always handled as simple string value No enforcement of xs:simpleType restriction facets, other than xs:enumeration 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.