Skip Headers

# Simple Type Translator

Previous

Next

The simple type translator is an extension of direct and direct collection mappings that lets you automatically translate an XML element value to an appropriate Java type based on the element's `<type>` attribute as defined in your XML schema.

You can use a simple type translator only when the mapping's XPath goes to a text node. You cannot use a simple type translator if the mapping's XPath goes to an attribute.

Using a simple type translator, you can make the XML document preserve type information. This is useful when your object model specifies generic object attributes such as `java.lang.Object` and `java.io.Serializable`, since they do not trigger specific type conversions in TopLink as do specific object attributes such as `java.lang.Integer` or `java.util.Calendar`.

Figure: Simple Type Translator illustrates a type translation XML mapping for the `number` attribute of the `PhoneNumber` class. Notice that the Java attribute is not specific enough to preserve the typing. The simple type translator adds the type information to the resulting document to preserve the typing.

Simple Type Translator

Description of " Simple Type Translator "

By default, TopLink uses built-in read and write conversion pairs (see "Default Read Conversions" and "Default Write Conversions").

You can override this behavior by specifying and configuring your own simple type translator, for example, to write XML binary data as `Base64`.

For more information, see "Configuring a Simple Type Translator".