Skip Headers

# Mapping a Union of Lists

Previous

Next

You can map a Java attribute to an `xsd:union` type whose `memberTypes` are `xsd:list` types where each `xsd:list` contains items of a single type, such as:

    <xsd:element name="listOfUnions" type="UnionOfLists"/>
        <xsd:simpleType name="UnionOfLists">
            <xsd:union memberTypes="xsd:double">
                <xsd:simpleType>
                    <xsd:list itemType="xsd:date"/>
                </xsd:simpleType>
                <xsd:simpleType>
                    <xsd:list itemType="xsd:integer"/>
                </xsd:simpleType>
            </xsd:union>
        </xsd:simpleType>

Note that in this example, valid XML documents contain either all `xsd:double`, all `xsd:date`, or all `xsd:integer` values.

If you represent the list in your object model as a `String` of white space delimited tokens (for example, `"aaa bbb ccc"`), use an `EISDirectMapping` (with XML records) or an `XMLDirectMappng` to map this Java attribute to an `xsd:list` (for example, `<item>aaa bbb ccc</item>`).

If you represent the list in your object model as a Java `List` type, use an `EISCompositeDirectCollectionMapping` (with XML records) or an `XMLCompositeDirectCollectionMapping`.

For more information, see the following:

- "Mapping to a Union of Lists With an XML Direct Mapping". The same applies to an `EISDirectMapping` with XML records (see "EIS Direct Mapping").

- "Mapping to a Union of Lists With an XML Composite Direct Collection Mapping". The same applies to an `EISCompositeDirectCollectionMapping` with XML records (see "EIS Composite Direct Collection Mapping").