Skip Headers

# Mapping to a List Field With an XML Direct Mapping

Previous

Next

Given the XML schema in Example: Schema for XML Direct Mapping to a List Field, Figure: XMLDirect Mapping to a List Field illustrates an XML direct mapping to an `xsd:list` type in a corresponding XML document when you represent the list in your object model as a `String` of white space delimited tokens. Example: Java for XML Direct Mapping to a List Field Node shows how to configure this mapping in Java.

Schema for XML Direct Mapping to a List Field

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="employee" type="employee-type"/>
        <xsd:complexType name="employee-type">
            <xsd:sequence>
                <xsd:element name="tasks" type="tasks-type"/>
            </xsd:sequence>
        </xsd:complexType>
        <xsd:simpleType name="tasks-type">
            <xsd:list itemType="xsd:string"/>
        </xsd:simpleType>
    </xsd:schema>

XMLDirect Mapping to a List Field

Description of "XMLDirect Mapping to a List Field"

Java for XML Direct Mapping to a List Field Node

    XMLDirectMapping tasksMapping = new XMLDirectMapping();
    tasksMapping.setAttributeName("tasks");
    XMLField myField = new XMLField("tasks/text()"); // pass in the XPath
    myField.setUsesSingleNode(true);
    tasksMapping.setField(myField);