Oracle Fusion Middleware Java API Reference for Oracle TopLink (Deprecated)
11g Release 1 (11.1.1)


Class XMLDirectMapping

  extended by oracle.toplink.mappings.DatabaseMapping
      extended by
          extended by oracle.toplink.ox.mappings.XMLDirectMapping
All Implemented Interfaces:, java.lang.Cloneable, oracle.toplink.ox.mappings.XMLMapping, oracle.toplink.ox.mappings.XMLNillableMapping
Direct Known Subclasses:
XMLBinaryDataMapping, XMLFragmentMapping

public class XMLDirectMapping
extends AbstractDirectMapping
implements oracle.toplink.ox.mappings.XMLMapping, oracle.toplink.ox.mappings.XMLNillableMapping

XML Direct Mappings map a Java attribute directly to XML attribute or text node.

XML Direct Mappings can be used in the following scenarios:

Setting the XPath: TopLink XML mappings make use of XPath statements to find the relevant data in an XML document. The XPath statement is relative to the context node specified in the descriptor. The XPath may contain node type, path, and positional information. The XPath is specified on the mapping using the setXPath method.

The following XPath statements may be used to specify the location of XML data relating to an object's name attribute:

XPath Description
@name The "@" character indicates that the node is an attribute.
text() "text()" indicates that the node is a text node. In this case the name value in the text node belongs to the context node.
full-name/text() The name information is stored in the text node of the full-name element.
personal-info/name/text() The XPath statement may be used to specify any valid path.
name[2]/text() The XPath statement may contain positional information. In this case the name information is stored in the text node of the second occurrence of the name element.

Mapping to a Specific Schema Type: In most cases TopLink can determine the target format in the XML document. However, there are cases where you must specify which one of a number of possible targets TopLink should use. For example, a java.util.Calendar could be marshalled to a schema date, time, or dateTime, or a byte[] could be marshalled to a schema hexBinary or base64Binary node.

XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="">
  <xsd:element name="customer" type="customer-type"/>
  <xsd:complexType name="customer-type">
      <xsd:element name="picture" type="xsd:hexBinary"/>
      <xsd:element name="resume" type="xsd:base64Binary"/>

Code Sample
XMLDirectMapping pictureMapping = new XMLDirectMapping();
XMLField pictureField = (XMLField) pictureMapping.getField();

Mapping to a Union Field:

XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="">
  <xsd:element name="customer" type="customer-type"/>
  <xsd:complexType name="customer-type">
      <xsd:element name="shoe-size" type="size-type"/>
  <xsd:simpleType name="size-type">
    <xsd:union memberTypes="xsd:decimal xsd:string"/>

Code Sample
XMLDirectMapping shoeSizeMapping = new XMLDirectMapping();
XMLUnionField shoeSizeField = new XMLUnionField();

Preserving the Node Type: 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.

Code Sample
XMLDirectMapping numberMapping = new XMLDirectMapping();
XMLField numberField = (XMLField) numberMapping.getField();

More Information: For more information about using the XML Direct Mapping, see the "Understanding XML Mappings" chapter of the Oracle TopLink Developer's Guide.

Oracle TopLink 10g Release 2 (10.1.3)
See Also:
Serialized Form

Field Summary
 boolean isCDATA
Constructor Summary
Method Summary
 java.lang.String getXPath()
          Get the XPath String
 boolean isCDATA()
 void setIsCDATA(boolean CDATA)
 void setNullPolicy(AbstractNullPolicy aNullPolicy)
          Set the AbstractNullPolicy on the mapping
The default policy is NullPolicy.
 void setXPath(java.lang.String xpathString)
          Set the Mapping field name attribute to the given XPath String
Methods inherited from class
getAttributeClassification, getConverter, getFieldClassification, getFieldName, getNullValue, hasConverter, isMutable, setAttributeClassification, setConverter, setConverterClassName, setField, setFieldClassification, setFieldType, setIsMutable, setNullValue
Methods inherited from class oracle.toplink.mappings.DatabaseMapping
getAttributeAccessor, getAttributeName, getGetMethodName, getProperty, getReferenceDescriptor, getSetMethodName, isLazy, isOptional, isUsingMethodAccess, readOnly, readWrite, setAttributeAccessor, setAttributeName, setGetMethodName, setIsLazy, setIsOptional, setIsReadOnly, setProperty, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


public boolean isCDATA
Constructor Detail


public XMLDirectMapping()
Method Detail


public void setNullPolicy(AbstractNullPolicy aNullPolicy)
Set the AbstractNullPolicy on the mapping
The default policy is NullPolicy.

Specified by:
setNullPolicy in interface oracle.toplink.ox.mappings.XMLNillableMapping
aNullPolicy -


public void setXPath(java.lang.String xpathString)
Set the Mapping field name attribute to the given XPath String

xpathString - String


public java.lang.String getXPath()
Get the XPath String

String the XPath String associated with this Mapping


public void setIsCDATA(boolean CDATA)


public boolean isCDATA()

Copyright © 1998, 2012, Oracle. All Rights Reserved.