background image

Schema Binding Declarations

<< Global Binding Declarations | Class Binding Declarations >>
<< Global Binding Declarations | Class Binding Declarations >>

Schema Binding Declarations

If typesafeEnumBase is set to xsd:string, it would be a global way to specify that all simple
type definitions deriving directly or indirectly from xsd:string and having enumeration
facets should be bound by default to a typesafe enum. If typesafeEnumBase is set to an
empty string, "", no simple type definitions would ever be bound to a typesafe enum class
by default. The value of typesafeEnumBase can be any atomic simple type definition except
xsd:boolean
and both binary types.
The JAXB implementation does not support the enableFailFastCheck attribute.
Note ­
Using typesafe enum classes enables you to map schema enumeration values to Java
constants, which in turn makes it possible to do compares on Java constants rather than
string values.
Schema Binding Declarations
The following code shows the schema binding declarations in po.xsd:
<jxb:schemaBindings>
<jxb:package name=
"primer.myPo">
<jxb:javadoc>
<![CDATA[<body> Package level documentation for generated package primer.myPo.</body>]]>
</jxb:javadoc>
</jxb:package>
<jxb:nameXmlTransform>
<jxb:elementName suffix=
"Element"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
<jxb:package name=
"primer.myPo"/> specifies the primer.myPo as the package in which
the schema-derived classes should be generated.
<jxb:nameXmlTransform>
specifies that all generated Java element interfaces should have
Element
appended to the generated names by default. For example, when the JAXB
compiler is run against this schema, the element interfaces CommentElement and
PurchaseOrderElement
will be generated. By contrast, without this customization, the
default binding would instead generate Comment and PurchaseOrder.
This customization is useful if a schema uses the same name in different symbol spaces; for
example, in global element and type definitions. In such cases, this customization enables
you to resolve the collision with one declaration rather than having to individually resolve
each collision with a separate binding declaration.
<jxb:javadoc>
specifies customized Javadoc tool annotations for the primer.myPo
package. Note that, unlike the <javadoc> declarations at the class level, below, the opening
and closing <body> tags must be included when the <javadoc> declaration is made at the
package level.
Customizing JAXB Bindings
The Java EE 5 Tutorial · September 2007
528