1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JiBX: Starting from Schema</title>
</head>
<body class="composite">
<div id="bodycol">
<div class="app">
<div class="h3">
<h3><a name="intro"></a>Starting from schema</h3>
<p>Generating Java code and binding definitions from XML schema definitions is easy with
JiBX. The <a href="%codegen%">CodeGen</a> 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:</p>
<ul>
<li>Import schema documentation as JavaDocs</li>
<li>Support for both untyped and typed (Java 5) collection classes</li>
<li>Support for both custom typesafe enumerations and Java 5 enums</li>
<li>Advanced schema analysis to keep the generated data model as simple as possible</li>
<li>Customization support to easily prune unnecessary or unused schema components from the data model</li>
</ul>
<p>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 <a href="%cgcustoms%#choice-handling"><code>choice-handling="stateless"</code></a>
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.</p>
<p>For an in-depth look at using CodeGen, see the
<a href="http://www.ibm.com/developerworks/java/tutorials/j-jibx2/">JiBX 1.2,
Part 2: XML schema to Java code</a> tutorial on the
<a href="http://www.ibm.com/developerworks">IBM developerWorks site</a>. You can also
look over the CodeGen examples included in the distribution, which are discussed in this
section of the documentation.</p>
<p>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.</p>
</div>
</div>
</div>
</body>
</html>
|