background image

Schema Binding Declarations

<< Global Binding Declarations | Class Binding Declarations >>
<< Global Binding Declarations | Class Binding Declarations >>
C
USTOMIZE
I
NLINE
E
XAMPLE
51
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.
Note: Using typesafe enums 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 inter-
faces should have
Element
appended to the generated names by default.
For example, when the JAXB compiler is run against this schema, the ele-
ment 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.