JAXB Examples
JAXB Examples
TABLE 178
JAXB Annotations Associated with Adapters
(Continued)
Annotation
Description and Default Setting
@XmlJavaTypeAdapters
A container annotation for defining multiple @XmlJavaTypeAdapter
annotations at the package level. Default Settings:
None
JAXB Examples
The sections that follow provide instructions for using the example Java applications that are
included in the tut-install/javaeetutorial5/examples/jaxb/ directory. These examples
demonstrate and build upon key JAXB features and concepts. Follow these procedures in the
order presented.
After reading this section, you should feel comfortable enough with JAXB that you can:
Generate JAXB Java classes from an XML schema
Use schema-derived JAXB classes to unmarshal and marshal XML content in a Java
application
Create a Java content tree from scratch using schema-derived JAXB classes
Validate XML content during unmarshalling and at runtime
Customize JAXB schema-to-Java bindings
This chapter describes three sets of examples:
The Basic examples (Modify Marshal, Unmarshal Validate) demonstrate basic JAXB
concepts like unmarshalling, marshalling, and validating XML content using default
settings and bindings.
The Customize examples (Customize Inline, Datatype Converter, External Customize)
demonstrate various ways of customizing the default binding of XML schemas to Java
objects.
The Java-to-Schema examples show how to use annotations to map Java classes to XML
schema.
Note
The Basic and Customize examples are based on a Purchase Order scenario. Each uses
an XML document, po.xml, written against an XML schema, po.xsd. These documents are
derived from the
, edited by David C. Fallside.
JAXB Examples
Chapter 17 · Binding between XML Schema and Java Classes
501