Skip Headers

# Mapping to a Union of Lists With an XML Direct Mapping

Previous

Next

Given the XML schema in Example: Schema for XML Direct Mapping to Union of Lists, Figure: XML Direct Mapping to Union of Lists illustrates an XML direct mapping to a union of lists in a corresponding XML document. Example: Java for XML Direct Mapping to Union of Lists shows how to configure this mapping in Java.

Schema for XML Direct Mapping to Union of Lists

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="vacation" 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>
    </xsd:schema>

XML Direct Mapping to Union of Lists

Description of "XML Direct Mapping to Union of Lists"

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

Java for XML Direct Mapping to Union of Lists

    XMLDirectMapping mapping = new XMLDirectMapping();
    mapping.setAttributeName("vacation");
    mapping.setXPath("UnionOfLists/text()");