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

EclipseLink/DesignDocs/293925/MOXyExtensions/XmlCollectionReferenceMapping

< EclipseLink‎ | DesignDocs‎ | 293925‎ | MOXyExtensions
Revision as of 10:00, 31 March 2010 by Unnamed Poltroon (Talk) (Basic XML collection reference mapping support)

XMLCollectionReferenceMapping

Requirements

Provide support for XML collection reference mapping configuration via XML metadata file.

The following should be configurable:

Design

Basic XML collection reference mapping support

We will extend our current xml-element and xml-attribute support to allow collection reference mapping configuration. For example, the following XML metadata snippet would be used to setup a collection reference mapping for 'workAddresses':

<xml-element java-attribute="workAddresses" xml-idref="true" />

Where the following exists in Address:

<xml-attribute java-attribute="id" xml-id="true" required="true" />

If workAddresses was to be mapped to an element named work-address-id, then the following would be used:

<xml-element java-attribute="workAddresses" xml-path="work-address-id/text()" xml-idref="true" />

Where the following exists in Address:

<xml-attribute java-attribute="id" xml-id="true" required="true" />

Example:

The following example will demonstrate how to configure XML collection reference mappings via XML metadata by using xml-element and xml-attribute.

org.example.Root.java

package org.example;
 
public class Root {
    public List<Employee> employees;
    public List<Address> addresses;
}

org.example.Employee.java

package org.example;
 
public class Employee {
    public List<Address> workAddresses;
}

org.example.Address.java

package org.example;
 
public class Address {
    public String id;
}

Deployment XML

 

XML Instance Document

<?xml version='1.0' encoding='UTF-8'?>
<document-root>
    <employee>
        <contact-info>
            <work-address-id>100</work-address-id>
            <work-address-id>101</work-address-id>
        </contact-info>
    </employee>
    <addresses>
        <address aid="100" />
        <address aid="101" />
        <address aid="102" />
    </addresses>
</document-root>

org/example/eclipselink-oxm.xml

This XML file demonstrates configuring XML collection reference mappings on the "org.example.Employee" class.

<?xml version="1.0" encoding="US-ASCII"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
    <java-types>
        <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Root">
            <xml-root-element name="document-root" />
            <java-attributes>
                <xml-element java-attribute="employees" xml-path="employee" />
                <xml-element java-attribute="addresses" xml-path="addresses/address" />
            </java-attributes>
        </java-type>
        <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Employee">
            <java-attributes>
                <xml-element java-attribute="workAddresses" xml-path="contact-info/work-address-id/text()" xml-idref="true" />
            </java-attributes>
        </java-type>
        <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.mappings.collectionreference.Address">
            <java-attributes>
                <xml-attribute java-attribute="id" xml-path="@aid" xml-id="true" required="true" />
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>

Open Issues

This section lists the open issues that are still pending that must be decided prior to fully implementing this project's requirements.

Issue# Owner Description/Notes

Decisions

This section lists decisions made. These are intended to document the resolution of open issues or constraints added to the project that are important.

Issue# Description/Notes Decision

Copyright © Eclipse Foundation, Inc. All Rights Reserved.