background image

Java-toSchema JAXB Examples

<< Basic JAXB Examples | JAXB Examples >>
<< Basic JAXB Examples | JAXB Examples >>
14
U
SING
JAXB
Table 3­3 briefly describes the Java-to-Schema examples.
Each Basic and Customize example directory contains several base files:
·
po.xsd
is the XML schema you will use as input to the JAXB binding
compiler, and from which schema-derived JAXB Java classes will be gen-
erated. For the Customize Inline and Datatype Converter examples, this
file contains inline binding customizations. Note that the Fix Collides
example uses
example.xsd
rather than
po.xsd
.
·
po.xml
is the Purchase Order XML file containing sample XML content,
and is the file you will unmarshal into a Java content tree in each example.
This file is almost exactly the same in each example, with minor content
Table 3­3 Java-toSchema JAXB Examples
Example Name
Description
j2s-create-marshal
Illustrates how to marshal and unmarshal JAXB-annotated classes
to XML schema. The example also shows how to enable JAXP
1.3 validation at unmarshal time using a schema file that was gen-
erated from the JAXB mapped classes.
j2s-xmlAccessorOrder
Illustrates how to use the @XmlAccessorOrder and @Xml-
Type.propOrder mapping annotations in Java classes to control the
order in which XML content is marshalled/unmarshaled by a Java
type.
j2s-xmlAdapter-field
Illustrates how to use the interface
XmlAdapter and the annota-
tion @XmlJavaTypeAdapter to provide a a custom mapping of
XML content into and out of a HashMap (field) that uses an "int"
as the key and a "string" as the value.
j2s-xmlAttribute-field
Illustrates how to use the annotation @XmlAttribute to define a
property or field to be handled as an XML attribute.
j2s-xmlRootElement
Illustrates how to use the annotation @XmlRootElement to define
an XML element name for the XML schema type of the corre-
sponding class.
j2s-xmlSchemaType-
class
Illustrates how to use the annotation @XmlSchemaType to cus-
tomize the mapping of a property or field to an XML built-in type.
j2s-xmlType
Illustrates how to use the annotation @XmlType to map a class or
enum type to an XML schema type.