Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Configuring an XML Descriptor (ELUG)

Revision as of 08:34, 21 November 2007 by Unnamed Poltroon (Talk) (New page: <div style="float:right;border:1px solid #000000;padding:5px">__TOC__ Related Topics</div> This section explains how to con...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This section explains how to configure descriptor options specific to an XML descriptor.

For information on how to configure descriptor options common to two or more descriptor types, see Configuring a Descriptor.


Introduction to XML Descriptor Configuration

This table lists the default configurable options for an XML descriptor.


Configuration Options for XML Descriptors

Option to Configure EclipseLink Workbench Java

XML schema namespace (see How to Configure XML Schema Namespace)

Supported

Supported

XML schema reference (see How to Configure an XML Schema Reference)

Supported

Supported

Schema context (see #Configuring Schema Context for an XML Descriptor)

Supported

Supported

Complex type of anyType (see #Configuring for Complex Type of anyType)

Supported

Unsupported.

Default root element (see #Configuring Default Root Element)

Supported

Supported

Document preservation (see #Configuring Document Preservation)

Supported

Supported

Comments (see Configuring Descriptor Comments)

Supported

Unsupported.

Classes (see How to Configure Classes)

Supported

Unsupported.

Inheritance for a child class descriptor (see Configuring Inheritance for a Child (Branch or Leaf) Class Descriptor)

Supported.

Supported.

Inheritance for a parent descriptor (see Configuring Inheritance for a Parent (Root) Descriptor)

Supported

Supported

Inherited attribute mapping in a subclass (see Configuring Inherited Attribute Mapping in a Subclass)

Supported.

Supported.

Instantiation policy (see Configuring Instantiation Policy)

Supported

Supported

Copy policy (see Configuring Copy Policy)

Supported

Supported

Amendment methods (see Configuring a Descriptor)

Supported

Supported

Mapping (see Configuring a Mapping)

Supported

Supported


For more information, see Introduction to XML Descriptors.

Configuring Schema Context for an XML Descriptor

The Workbench uses the schema context to associate the XML descriptor reference class with a simple or complex type in one of the schemas associated with the XML project (see How to Configure an XML Schema Reference). This allows the Workbench to display the appropriate attributes available for mapping in that context.

You must configure the schema context for an XML descriptor regardless of whether or not you are using the Workbench.

The EclipseLink runtime uses the schema context to validate XML fragments.


How to Configure Schema Context for an XML Descriptor Using Workbench

To associate an XML descriptor with a specific schema complex type, use this procedure:

  1. Select an XML descriptor in the Navigator. Its properties appear in the Editor.
  2. Click the Descriptor Info tab. The Descriptor Info tab appears.
    Descriptor Info Tab, Schema Context Option
    Descriptor Info Tab, Schema Context Option
  3. Complete the Schema Context field on the tab.

Click Browse to select the schema element to associate with this descriptor. For more information, see [[[#Choosing a Schema Context]].

See Also

#Configuring Schema Context for an XML Descriptor
Configuring a Descriptor


Choosing a Schema Context

Use the Choose Schema Context dialog box to select a specific schema element (such as when mapping an element).

Choose Schema Context Dialog Box

Choose Schema Context Dialog Box

Select a schema element and click OK.

How to Configure Schema Context for an XML Descriptor Using Java

To configure an XML descriptor with a schema context using Java, create a descriptor amendment method (see Configuring a Descriptor) that uses XMLSchemaReference method setSchemaContext, as this example shows.


Configuring Schema Context

public void addToDescriptor(ClassDescriptor descriptor) {
    descriptor.getSchemaReference().setSchemaContext(xPath);
}


Configuring for Complex Type of anyType

This attribute applies only to Workbench. Use this option to solve "No schema context is specified" problems (see How to Use the Problems Window) for an XML descriptor that does not represent an element in your XML schema.

In general, Workbench assumes that every XML descriptor must have a schema context (see #Configuring Schema Context for an XML Descriptor). However, if a class in your project does not relate to an element in your schema, then it does not have a schema context.

For example, consider the schema that this exmaple shows.


Schema Using xsd:anyType

<?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="contact-method" type="xsd:anyType"/>
        </xsd:sequence>
    </xsd:complexType>

    <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:element name="phone-number" type="xsd:string"/>
</xsd:schema>


Because element contact-method is of type xsd:anyType, your project requires a class to represent that type, such as class AnyTypeImpl shown in Class Representing xsd:anyType. Because this class does not relate to any complex type in your schema, it has no schema context. In this example, you would select this option for the AnyTypeImpl class.


Class Representing xsd:anyType

Class Representing xsd:anyType


For more information, see xs:any and xs:anyType Support.


How to Configure Complex Type of anyType Using Workbench

To specify that the descriptor represents a complex type of anyType, use this procedure:

  1. Select a descriptor in the Navigator. Its properties appear in the Editor.
  2. Click the Descriptor Info tab. The Descriptor Info tab appears.
    Descriptor Info Tab, Complex Type "anyType" Option
    Descriptor Info Tab, Complex Type "anyType" Option

Select the Descriptor Represents Complex Type "anyType" option to specify this descriptor as the root element.

Configuring Default Root Element

The default root element is the name that EclipseLink uses for the root element when marshalling objects for this descriptor to, and unmarshalling from, an XML document. Descriptors used only in composite relationship mappings do not require a default root element.

For more information, see Default Root Element.


How to Configure Default Root Element Using Workbench

To specify a schema element as the default root element for the descriptor, use this procedure:

  1. Select a descriptor in the Navigator. Its properties appear in the Editor.
  2. Click the Descriptor Info tab. The Descriptor Info tab appears.
    Descriptor Info Tab, Default Root Option
    Descriptor Info Tab, Default Root Option

Select the Default Root Element option to specify this descriptor as the root element.

Click Browse to select the schema element to identify as the root element for this descriptor. See #Choosing a Root Element for more information.

See Also

#Configuring Default Root Element


Choosing a Root Element

Use the Choose Root Element dialog box to select a specific root element.

Choose Root Element Dialog Box

Choose Root Element Dialog Box

Select the root element and click OK.


Configuring Document Preservation

EclipseLink lets you preserve any "extra" data in your XML source that is not required to map to an object model (such as comments, processing instructions, or unmapped elements).

This permits round-tripping from XML to objects and back to XML without losing any data.


How to Configure Document Preservation Using Workbench

To preserve the entire XML source document, use this procedure:

  1. Select a descriptor in the Navigator. Its properties appear in the Editor.
  2. Click the Descriptor Info tab. The Descriptor Info tab appears.
    Descriptor Info Tab, Preserve Document Option
    Descriptor Info Tab, Preserve Document Option

Select the Preserve Document option to maintain any extra information from the source XML document that EclipseLink does not require (such as comments).

See Also

#Configuring Document Preservation
Configuring a Descriptor


How to Configure Document Preservation Using Java

To configure an XML descriptor to maintain any extra information from the source XML document that EclipseLink does not require (such as comments) using Java, create a descriptor amendment method (see Configuring a Descriptor) that configures the descriptor using XMLDescriptor method setShouldPreserveDocument.



Copyright Statement

Back to the top