Skip Headers

# Mapping to a Text Node by Position

Previous

Next

Given the XML schema in Example: Schema for XML Direct Mapping to Text Node by Position, Figure: XML Direct Mapping to Text Node by Position illustrates an XML direct mapping to a text node by position in a corresponding XML document. Example: Java for XML Direct Mapping to Text Node by Position shows how to configure this mapping in Java.

Schema for XML Direct Mapping to Text Node by Position

    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="customer" type="customer-type"/>
        <xsd:complexType name="customer-type">
            <xsd:sequence>
                <xsd:element name="name" type="xsd:string" maxOccurs="2"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:schema>

XML Direct Mapping to Text Node by Position

Description of "XML Direct Mapping to Text Node by Position"

Java for XML Direct Mapping to Text Node by Position

    XMLDirectMapping firstNameMapping = new XMLDirectMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setXPath("name[1]/text()");

    XMLDirectMapping lastNameMapping = new XMLDirectMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setXPath("name[2]/text()");