Skip Headers

# Mapping to a List of Unions With an XML Composite Direct Collection Mapping

Previous

Next

Given the XML schema in Example: Schema for XML Composite Direct Collection Mapping to List of Unions, Figure: Composite XML Direct Collection Mapping to List of Unions illustrates a composite direct collection XML mapping to a list of unions in a corresponding XML document. Example: Java for XML Composite Direct Collection Mapping to List of Unions shows how to configure this mapping in Java.

Schema for XML Composite Direct Collection Mapping to List of Unions

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="vacation" type="listOfUnions"/>
        <xsd:simpleType name="listOfUnions">
            <xsd:list>
                <xsd:simpleType>
                    <xsd:union memberTypes="xsd:date xsd:integer"/>
                </xsd:simpleType>
            </xsd:list>
        </xsd:simpleType>
    </xsd:schema>

Composite XML Direct Collection Mapping to List of Unions

Description of "Composite XML Direct Collection Mapping to List of Unions"

Java for XML Composite Direct Collection Mapping to List of Unions

    XMLCompositeDirectCollectionMapping mapping = new XMLCompositeDirectCollectionMapping();
    mapping.setAttributeName("myattribute");
    XMLUnionField field = new XMLUnionField("listOfUnions/text()");
    mapping.addSchemaType(new Qname(url,"int"));
    mapping.addSchemaType(new Qname(url,"date"));
    mapping.setField(field);
    mapping.useSingleElement(false);