A JAXB Tutorial
Wolfgang Laun
Thales Austria GmbH

    1 Introduction
        1.1 About JAXB
        1.2 Overview
        1.3 Hello World
    2 Writing an XML Schema for JAXB
        2.1 XML Schema Types
        2.2 JAXB Examples
            2.2.1 Defining an Integer Range Type
            2.2.2 Numeric Types
            2.2.3 Defining a String with Length Limits
            2.2.4 Defining a String Type Restricted By Pattern
            2.2.5 Date and Time
            2.2.6 Binary Data
            2.2.7 Defining a List of Integers
            2.2.8 Defining Other Lists
            2.2.9 Defining an Enumeration
            2.2.10 Defining a Type Union
            2.2.11 Defining Types for XML Elements Without Content
            2.2.12 Defining Types for XML Elements With Content
                2.2.12.1 Content: A Value
                2.2.12.2 Content: An Ordered Set of Elements
                2.2.12.3 Content: An Unordered Set of Elements
                2.2.12.4 Content: Alternative Elements
                2.2.12.5 Content: A Homogeneous List of Elements
                2.2.12.6 Content: A Mixed List of Elements
                2.2.12.7 Mixed Content
                2.2.12.8 No Value
            2.2.13 Defining Subtypes
            2.2.14 Substitution Groups
            2.2.15 Referring to Another XML Element
            2.2.16 Elements With Any Type
                2.2.16.1 DOM Elements
                2.2.16.2 Another Content Tree as Element
            2.2.17 Image Data
        2.3 Hints on Writing XML Schemas
            2.3.1 Don't Use Anonymous Types
            2.3.2 Common Schema Definitions
            2.3.3 A Note on Groups
            2.3.4 Conserving Compatibility
            2.3.5 Spurious Classes
            2.3.6 Avoid Unnecessary JAXBElement<?>
    3 Unmarshalling and Using the Data
        3.1 Unmarshalling
        3.2 Using the Element Tree
        3.3 Validation
        3.4 Validation Event Handling
        3.5 The JAXB Context
    4 Building and Marshalling an XML Document
        4.1 The Object Factory
        4.2 Assembling Document Tree Nodes
        4.3 Assembling Data with Links (ID, IDREF)
            4.3.1 One Element per Identification
            4.3.2 Preserving Object Identity
        4.4 Last Resort: Assembling a Java Object
        4.5 Calling marshal
    5 Customizing
        5.1 Reasons for Customizing
        5.2 Defining Package Names
        5.3 Overriding Names
        5.4 Adding Documentation
        5.5 Interning Strings
        5.6 Overriding the Datatype
            5.6.1 Replacing the Conversions
            5.6.2 Replacing a Simple Type
    6 JAXB Annotations
        6.1 How a Schema Mapping Is Implemented
        6.2 A Survey Of JAXB Annotations
            6.2.1 Top-level Elements: XmlRootElement
            6.2.2 Annotation for Classes: XmlType
            6.2.3 Annotations for the Schema: XmlSchema
            6.2.4 The Object Factory: XmlRegistry, XmlElementDecl
            6.2.5 Controlling Element Selection: XmlAccessorType, XmlTransient
            6.2.6 Class Inclusion: XmlSeeAlso
            6.2.7 Annotations for Fields
                6.2.7.1 The Annotation XmlElement
                6.2.7.2 The Annotation XmlList
                6.2.7.3 Class Fields as Attributes: XmlAttribute
                6.2.7.4 Mapping a Class to Simple Content or Simple Type: XmlValue
                6.2.7.5 Collecting Unspecified Attributes: XmlAnyAttribute
                6.2.7.6 Collecting Unspecified Elements: XmlAnyElement
                6.2.7.7 Wrapping Repeated Elements: XmlElementWrapper
                6.2.7.8 Annotations for Mixed Content: XmlElementRef, XmlMixed
            6.2.8 Annotations for Enums: @XmlEnum, @XmlEnumValue
            6.2.9 Type Adapters: XmlJavaTypeAdapter
            6.2.10 Type Mapping: XmlSchemaType
            6.2.11 Annotations for Object References: XmlID, XmlIDREF