Skip Headers

# Mapping to an Element

Previous

Next

Given the XML schema in Example: Schema for XML Composite Object Mapping to an Element, Figure: XML Composite Object Mapping to an Element illustrates an XML composite object mapping to an element in a corresponding XML document. Example: Java for XML Composite Object Mapping to an Element shows how to configure this mapping in Java.

Schema for XML Composite Object Mapping to an Element

    <?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="first-name" type="xsd:string"/>
                <xsd:element name="last-name" type="xsd:string"/>
                <xsd:element name="address">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="street" type="xsd:string"/>
                            <xsd:element name="city" type="xsd:string"/>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:schema>

XML Composite Object Mapping to an Element

Description of "XML Composite Object Mapping to an Element"

Java for XML Composite Object Mapping to an Element

    XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
    addressMapping.setAttributeName("address");
    addressMapping.setXPath("address");
    addressMapping.setReferenceClass(Address.class);