Skip Headers

# group Structure Containing a group

Previous

Next

You can use the `jaxb:class` customization with a `group` structure that contains another `group` structure as Example: jaxb:class Customization of a group Structure Containing a group shows.

jaxb:class Customization of a group Structure Containing a group

    <xsd:group name="G1">
        <xsd:annotation>
            <xsd:appinfo>
                <jaxb:class name="EmploymentInfo"/>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <xsd:element name="id" type="xsd:int"/>
            <xsd:group ref="G2"/>
        </xsd:sequence>
    </xsd:group>

    <xsd:group name="G2">
        <xsd:annotation>
            <xsd:appinfo>
                <jaxb:class name="Period"/>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:sequence>
            <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:group ref="G1"/>
        </xsd:complexType>
    </xsd:element>

This directs the JAXB compiler to create a wrapper class named `EmploymentInfo` for the `group` structure that the owning element's class references and another wrapper class named `Period` for the `group` structure that the `EmploymentInfo` class references. Use an `EISCompositeObjectMapping` (with XML records) or an `XMLCompositeObjectMapping` to map a Java attribute to these wrapper classes.

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