Skip to main content
Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/293925/Phase6"

Line 73: Line 73:
 
<?xml version="1.0" encoding="US-ASCII"?>
 
<?xml version="1.0" encoding="US-ASCII"?>
 
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
 
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
<java-types>
+
    <java-types>
<java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.xmlelements.Foo">
+
        <java-type name="org.eclipse.persistence.testing.jaxb.externalizedmetadata.xmlelements.Foo">
 
             <xml-root-element name="foo"/>
 
             <xml-root-element name="foo"/>
 
             <java-attributes>
 
             <java-attributes>
Line 82: Line 82:
 
                 </xml-elements>
 
                 </xml-elements>
 
             </java-attributes>
 
             </java-attributes>
</java-type>
+
        </java-type>
</java-types>
+
    </java-types>
 
</xml-bindings>
 
</xml-bindings>
 
</source>
 
</source>

Revision as of 14:05, 2 December 2009

Phase 6 - Substitution Groups (page under construction)

Provide support for substitution groups.

Annotations

The following annotations will be targeted in this phase:

Annotation XML Metadata Tag Package Type Field Method
XmlElements xml-elements     X X
XmlElementRef xml-element-ref     X X
XmlElementRefs xml-element-refs X
X

Example: XmlElements annotation

Java Metadata

The following example will demonstrate how the XmlElements annotation can be applied:

org.example.Foo.java

package org.example;
 
@javax.xml.bind.annotation.XmlRootElement
public class Foo {
    @javax.xml.bind.annotation.XmlElementWrapper(name="items")
    @javax.xml.bind.annotation.XmlElements({
        @javax.xml.bind.annotation.XmlElement(name="A", type=Integer.class),
        @javax.xml.bind.annotation.XmlElement(name="B", type=Float.class)
    })
    public java.util.List items;
}

XML Metadata

xml-elements

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.Foo" 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.xmlelements.Foo">
            <xml-root-element name="foo"/>
            <java-attributes>
                <xml-elements java-attribute="items">
                    <xml-element java-attribute="A" type="java.lang.Integer" />
                    <xml-element java-attribute="B" type="java.lang.Float" />
                </xml-elements>
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>

Back to the top