Skip Headers

# group Structure Containing a sequence or choice

Previous

Next

You can use the `jaxb:class` customization with a `group` structure that contains a `sequence` or `choice`. Example: jaxb:class Customization of a group Structure Containing a sequence shows a `jaxb:class` customization of a `group` structure containing a `sequence` structure.

jaxb:class Customization of a group Structure Containing a sequence

    <xsd:group name="G1">
        <xsd:annotation>
            <xsd:appinfo>
                <jaxb:class name="EmploymentInfo"/>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:annotation>
                <xsd:appinfo>
                    <jaxb:class name="Period"/>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:element name="startDate" type="xsd:date"/>
            <xsd:element name="endDate" type="xsd:date"/>
        </xsd:sequence>
    </xsd:group>

    <xsd:element name="employee">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="id" type="xsd:int"/>
                <xsd:group ref="G1"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

This directs the JAXB compiler to create an external wrapper class named `EmploymentInfo` for the `group` structure and an inner class named `Period` in the external wrapper class for the `sequence` structure. The owning element references the external wrapper class. Use an `EISCompositeObjectMapping` (with XML records) or an `XMLCompositeObjectMapping` to map a Java attribute to this external wrapper class.

For more information, see "XML Composite Object Mapping". The same applies to an `EISCompositeObjectMapping` with XML records (see "EIS Composite Object Mapping").