background image

Customize Inline Example

<< JCustomization Namespace Prefix | Global Binding Declarations >>
<< JCustomization Namespace Prefix | Global Binding Declarations >>
C
USTOMIZE
I
NLINE
E
XAMPLE
49
customize with standard JAXB binding declarations must include the JAXB
namespace declaration and JAXB version number at the top of the schema file.
For example, in
po.xsd
for the Customize Inline example, the namespace decla-
ration is as follows:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="1.0">
A binding declaration with the
jxb
namespace prefix would then take the form:
<xsd:annotation>
<xsd:appinfo>
<jxb:globalBindings binding declarations />
<jxb:schemaBindings>
.
.
binding declarations
.
.
</jxb:schemaBindings>
</xsd:appinfo>
</xsd:annotation>
Note that in this example, the
globalBindings
and
schemaBindings
declara-
tions are used to specify, respectively, global scope and schema scope customi-
zations. These customization scopes are described in more detail in Scope,
Inheritance, and Precedence (page 40).
Customize Inline Example
The Customize Inline example illustrates some basic customizations made by
means of inline annotations to an XML schema named
po.xsd
. In addition, this
example implements a custom datatype converter class,
MyDatatypeCon-
verter.java
, which illustrates print and parse methods in the
<javaType>
cus-
tomization for handling custom datatype conversions.
To summarize this example:
1.
po.xsd
is an XML schema containing inline binding customizations.
2.
MyDatatypeConverter.java
is a Java class file that implements print and
parse methods specified by
<javaType>
customizations in
po.xsd
.