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/277920/Phase4"

Line 41: Line 41:
 
|}
 
|}
  
== Example: XmlElementWrapper ==
+
== Example: XmlElementWrapper and XmlValue annotations ==
  
 
=== Java Metadata  ===
 
=== Java Metadata  ===
  
The following example will demonstrate how an [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlElementWrapper.html XmlElementWrapper] annotation can be applied:
+
The following example will demonstrate how the [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlElementWrapper.html XmlElementWrapper] and [http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlValue.html XmlValue] annotations can be applied:
  
 
==== org.example.Employee.java  ====
 
==== org.example.Employee.java  ====
Line 57: Line 57:
 
     @XmlElementWrapper(name="my-digits", namespace="urn:employee", nillable=true, required=true)
 
     @XmlElementWrapper(name="my-digits", namespace="urn:employee", nillable=true, required=true)
 
     public int[] digits;
 
     public int[] digits;
 +
 +
    @XmlValue
 +
    public java.math.BigDecimal salary;
 
}
 
}
 
</source>
 
</source>
Line 63: Line 66:
  
 
==== xml-element-wrapper  ====
 
==== xml-element-wrapper  ====
 +
 +
If this is present in the XML then it completely replaces the corresponding annotation.
 +
 +
==== xml-value  ====
  
 
If this is present in the XML then it completely replaces the corresponding annotation.  
 
If this is present in the XML then it completely replaces the corresponding annotation.  
Line 77: Line 84:
 
         <java-attributes>
 
         <java-attributes>
 
             <xml-element-wrapper java-attribute="digits" name="my-digits" namespace="urn:employee" nillable="true" required="true"/>
 
             <xml-element-wrapper java-attribute="digits" name="my-digits" namespace="urn:employee" nillable="true" required="true"/>
 +
            <xml-value java-attribute="salary" />
 
         </java-attributes>
 
         </java-attributes>
 
     </java-type>
 
     </java-type>

Revision as of 14:48, 13 October 2009

Phase 4 (page under construction)

Provide support for high level metadata.

Annotations

The following annotations will be targetted in this phase:


Annotation Package Type Field Method
XmlElementWrapper
    X X
XmlList
    X X
XmlValue
X X
XmlMixed
  X
X

Example: XmlElementWrapper and XmlValue annotations

Java Metadata

The following example will demonstrate how the XmlElementWrapper and XmlValue annotations can be applied:

org.example.Employee.java

package org.example;
 
import javax.xml.bind.annotation.XmlElementWrapper;
 
public class Employee {
    @XmlElementWrapper(name="my-digits", namespace="urn:employee", nillable=true, required=true)
    public int[] digits;
 
    @XmlValue
    public java.math.BigDecimal salary;
}

XML Metadata

xml-element-wrapper

If this is present in the XML then it completely replaces the corresponding annotation.

xml-value

If this is present in the XML then it completely replaces the corresponding annotation.

org/example/eclipselink-oxm.xml

This XML file represents metadata overrides for 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.example.Employee">
        <java-attributes>
            <xml-element-wrapper java-attribute="digits" name="my-digits" namespace="urn:employee" nillable="true" required="true"/>
            <xml-value java-attribute="salary" />
        </java-attributes>
    </java-type>
  </java-types>
</xml-bindings>

Back to the top