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

Difference between revisions of "EclipseLink/DesignDocs/293925/MOXyExtensions/XmlTransformationMapping"

(org.example.Employee.java)
(org.example.Employee.java)
Line 76: Line 76:
 
     @XmlTransformation(attribute-method="buildNameAttribute",
 
     @XmlTransformation(attribute-method="buildNameAttribute",
 
         field-transformations = {
 
         field-transformations = {
             @FieldTransformation(xml-path="name/text()",  
+
             @FieldTransformation(xml-path="name/text()", method-name="buildNameField")
                                                                      method-name="buildNameField")
+
 
         }
 
         }
 
     )*
 
     )*
Line 86: Line 85:
 
         field-transformers = {
 
         field-transformers = {
 
             @FieldTransformer(xml-path="normal-hours/start-time/text()",  
 
             @FieldTransformer(xml-path="normal-hours/start-time/text()",  
                                                            transformer-class="org.example.StartTimeTransformer"),
+
                    transformer-class="org.example.StartTimeTransformer"),
 
             @FieldTransformer(xml-path="normal-hours/end-time/text()",  
 
             @FieldTransformer(xml-path="normal-hours/end-time/text()",  
                                                            transformer-class="org.example.EndTimeTransformer"),
+
                    transformer-class="org.example.EndTimeTransformer"),
 
         }
 
         }
 
     )*
 
     )*

Revision as of 13:57, 23 March 2010

XMLTransformationMapping

Requirements

Provide support for XML transformation mapping configuration via XML metadata file.

The following should be supported:

  • Get/set method names
  • Attribute Method
  • Attribute Transformer
  • Field transformer
  • Field transformations
  • Read only
  • Write only
  • Mutable

XML Schema

Following is the proposed schema change required to support Xml transformation mappings:

<xs:element name="xml-transformation" substitutionGroup="java-attribute">
    <xs:complexType>
        <xs:complexContent>
            <xs:extension base="java-attribute">
                <xs:all>
                    <xs:element ref="xml-access-methods" minOccurs="0" />
                    <xs:element name="field-transformations" minOccurs="0">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="field-transformation" maxOccurs="unbounded">
                                    <xs:complexType>
                                        <xs:attribute name="xml-path" type="xs:string" />
                                        <xs:attribute name="method-name" type="xs:string" />
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                    <xs:element name="field-transformers" minOccurs="0">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="field-transformer" maxOccurs="unbounded">
                                    <xs:complexType>
                                        <xs:attribute name="xml-path" type="xs:string" />
                                        <xs:attribute name="transformer-class" type="xs:string" />
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:all>
                <xs:attribute name="attribute-method" type="xs:string" />
                <xs:attribute name="attribute-transformer" type="xs:string" />
                <xs:attribute name="mutable" type="xs:boolean" default="false" />
                <xs:attribute name="read-only" type="xs:boolean" default="false" />
                <xs:attribute name="write-only" type="xs:boolean" default="false" />
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:element>

Example

The follow demonstrates how an XML transformation mapping can be configured via XML metadata:

org.example.Employee.java

package org.example;
 
import org.eclipse.persistence.oxm.annotations.FieldTransformation;
import org.eclipse.persistence.oxm.annotations.FieldTransformer;
import org.eclipse.persistence.oxm.annotations.XmlAccessMethods;
import org.eclipse.persistence.oxm.annotations.XmlTransformation;
 
public class Employee {
 
    @XmlTransformation(attribute-method="buildNameAttribute",
        field-transformations = {
            @FieldTransformation(xml-path="name/text()", method-name="buildNameField")
        }
    )*
    @XmlAccessMethods(get-method="getName", set-method="setName")*
    protected String name;
 
    @XmlTransformation(attribute-transformer="org.example.NormalHoursAttributeTransformer",
        field-transformers = {
            @FieldTransformer(xml-path="normal-hours/start-time/text()", 
                     transformer-class="org.example.StartTimeTransformer"),
            @FieldTransformer(xml-path="normal-hours/end-time/text()", 
                     transformer-class="org.example.EndTimeTransformer"),
        }
    )*
    @XmlAccessMethods(get-method="getNormalHours", set-method="setNormalHours")*
    protected String[] normalHours;
}
  • Note that the XmlTransformation, FieldTransformation, XmlAccessMethods, and FieldTransformer annotations do not exist and are intended for example purposes only.

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

Back to the top