Skip Headers

# Mapping With a Simple Type Translator

Previous

Next

If the type of a node is not defined in your XML schema, you can configure an XML direct mapping to use the `xsi:type` attribute to provide type information.

Given the XML schema fragment in Example: Schema for XML Direct Mapping with Simple Type Translator, Figure: Java Class for XML Direct Mapping with Simple Type Translator illustrates a Java class that can be mapped to a corresponding XML document.

Schema for XML Direct Mapping with Simple Type Translator

    ...
        <xs:element name="area-code" type="anySimpleType"/>
        <xs:element name="number" type="anySimpleType"/>
    ...

Java Class for XML Direct Mapping with Simple Type Translator

Description of "Java Class for XML Direct Mapping with Simple Type Translator"

Figure: XML Direct Mapping with a Simple Type Translator illustrates an XML direct mapping with a simple type translator in an XML document that conforms to the schema in Example: Schema for XML Direct Mapping with Simple Type Translator.

XML Direct Mapping with a Simple Type Translator

Description of "XML Direct Mapping with a Simple Type Translator"

Example: Java for XML Direct Mapping with Simple Type Translator shows how to configure this mapping in Java.

Java for XML Direct Mapping with Simple Type Translator

    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setXPath("number/text()");
    XMLField numberField = (XMLField) numberMapping.getField();
    numberField.setIsTypedTextField(true);

For more information, see "Simple Type Translator".