Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Configuring an XML Descriptor (ELUG)"

m (New page: <div style="float:right;border:1px solid #000000;padding:5px">__TOC__ Related Topics</div> This section explains how to con...)
 
m (Introduction to XML Descriptor Configuration)
Line 23: Line 23:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r2c1-t2" headers="r1c1-t2" align="left" |
 
| id="r2c1-t2" headers="r1c1-t2" align="left" |
XML schema namespace (see [[Using%20Workbench%20(ELUG)|How to Configure XML Schema Namespace]])
+
[[Using%20Workbench%20(ELUG)#How to Configure XML Schema Namespace|XML schema namespace]]
 
| headers="r2c1-t2 r1c2-t2" align="left" |
 
| headers="r2c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 30: Line 30:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r3c1-t2" headers="r1c1-t2" align="left" |
 
| id="r3c1-t2" headers="r1c1-t2" align="left" |
XML schema reference (see [[Using%20Workbench%20(ELUG)|How to Configure an XML Schema Reference]])
+
[[Using%20Workbench%20(ELUG)#How to Configure an XML Schema Reference|XML schema reference]]
 
| headers="r3c1-t2 r1c2-t2" align="left" |
 
| headers="r3c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 37: Line 37:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r4c1-t2" headers="r1c1-t2" align="left" |
 
| id="r4c1-t2" headers="r1c1-t2" align="left" |
Schema context (see [[#Configuring Schema Context for an XML Descriptor]])
+
[[#Configuring Schema Context for an XML Descriptor|Schema context]]
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 44: Line 44:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r5c1-t2" headers="r1c1-t2" align="left" |
 
| id="r5c1-t2" headers="r1c1-t2" align="left" |
Complex type of anyType (see [[#Configuring for Complex Type of anyType]])
+
[[#Configuring for Complex Type of anyType|Complex type of anyType]]
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 51: Line 51:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r6c1-t2" headers="r1c1-t2" align="left" |
 
| id="r6c1-t2" headers="r1c1-t2" align="left" |
Default root element (see [[#Configuring Default Root Element]])
+
[[#Configuring Default Root Element|Default root element]]
 
| headers="r6c1-t2 r1c2-t2" align="left" |
 
| headers="r6c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 58: Line 58:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r7c1-t2" headers="r1c1-t2" align="left" |
 
| id="r7c1-t2" headers="r1c1-t2" align="left" |
Document preservation (see [[#Configuring Document Preservation]])
+
[[#Configuring Document Preservation|Document preservation]]
 
| headers="r7c1-t2 r1c2-t2" align="left" |
 
| headers="r7c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 65: Line 65:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r8c1-t2" headers="r1c1-t2" align="left" |
 
| id="r8c1-t2" headers="r1c1-t2" align="left" |
Comments (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring Descriptor Comments]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring Descriptor Comments|Comments]]
 
| headers="r8c1-t2 r1c2-t2" align="left" |
 
| headers="r8c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 72: Line 72:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r9c1-t2" headers="r1c1-t2" align="left" |
 
| id="r9c1-t2" headers="r1c1-t2" align="left" |
Classes (see [[Using%20Workbench%20(ELUG)|How to Configure Classes]])
+
[[Using%20Workbench%20(ELUG)#How to Configure Classes|Classes]]
 
| headers="r9c1-t2 r1c2-t2" align="left" |
 
| headers="r9c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 79: Line 79:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r10c1-t2" headers="r1c1-t2" align="left" |
 
| id="r10c1-t2" headers="r1c1-t2" align="left" |
Inheritance for a child class descriptor (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring Inheritance for a Child (Branch or Leaf) Class Descriptor]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring Inheritance for a Child (Branch or Leaf) Class Descriptor|Inheritance for a child class descriptor]]
 
| headers="r10c1-t2 r1c2-t2" align="left" |
 
| headers="r10c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported.]]
 
[[Image:support.gif|Supported.]]
Line 86: Line 86:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r11c1-t2" headers="r1c1-t2" align="left" |
 
| id="r11c1-t2" headers="r1c1-t2" align="left" |
Inheritance for a parent descriptor (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring Inheritance for a Parent (Root) Descriptor]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring Inheritance for a Parent (Root) Descriptor|Inheritance for a parent descriptor]]
 
| headers="r11c1-t2 r1c2-t2" align="left" |
 
| headers="r11c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 93: Line 93:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r12c1-t2" headers="r1c1-t2" align="left" |
 
| id="r12c1-t2" headers="r1c1-t2" align="left" |
Inherited attribute mapping in a subclass (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring Inherited Attribute Mapping in a Subclass]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring Inherited Attribute Mapping in a Subclass|Inherited attribute mapping in a subclass]]
 
| headers="r12c1-t2 r1c2-t2" align="left" |
 
| headers="r12c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported.]]
 
[[Image:support.gif|Supported.]]
Line 100: Line 100:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r13c1-t2" headers="r1c1-t2" align="left" |
 
| id="r13c1-t2" headers="r1c1-t2" align="left" |
Instantiation policy (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring Instantiation Policy]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring Instantiation Policy|Instantiation policy]]
 
| headers="r13c1-t2 r1c2-t2" align="left" |
 
| headers="r13c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 107: Line 107:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r14c1-t2" headers="r1c1-t2" align="left" |
 
| id="r14c1-t2" headers="r1c1-t2" align="left" |
Copy policy (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring Copy Policy]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring Copy Policy|Copy policy]]
 
| headers="r14c1-t2 r1c2-t2" align="left" |
 
| headers="r14c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 114: Line 114:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r15c1-t2" headers="r1c1-t2" align="left" |
 
| id="r15c1-t2" headers="r1c1-t2" align="left" |
Amendment methods (see [[Configuring%20a%20Descriptor%20(ELUG)|Configuring a Descriptor]])
+
[[Configuring%20a%20Descriptor%20(ELUG)#Configuring a Descriptor|Amendment methods]]
 
| headers="r15c1-t2 r1c2-t2" align="left" |
 
| headers="r15c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 121: Line 121:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r16c1-t2" headers="r1c1-t2" align="left" |
 
| id="r16c1-t2" headers="r1c1-t2" align="left" |
Mapping (see [[Configuring%20a%20Mapping%20(ELUG)|Configuring a Mapping]])
+
[[Configuring%20a%20Mapping%20(ELUG)#Configuring a Mapping|Mapping]]
 
| headers="r16c1-t2 r1c2-t2" align="left" |
 
| headers="r16c1-t2 r1c2-t2" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]

Revision as of 10:51, 3 December 2007


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

Supported

Supported

XML schema reference

Supported

Supported

Schema context

Supported

Supported

Complex type of anyType

Supported

Unsupported.

Default root element

Supported

Supported

Document preservation

Supported

Supported

Comments

Supported

Unsupported.

Classes

Supported

Unsupported.

Inheritance for a child class descriptor

Supported.

Supported.

Inheritance for a parent descriptor

Supported

Supported

Inherited attribute mapping in a subclass

Supported.

Supported.

Instantiation policy

Supported

Supported

Copy policy

Supported

Supported

Amendment methods

Supported

Supported

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