Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/406697"

Line 151: Line 151:
*don`t write out that property itself as nested if it is the variable field - currently need to mark that property as transient.
*don`t write out that property itself as nested if it is the variable field - currently need to mark that property as transient.
*startcollection and endcollection [ ]'s in JSON
*in conjunction with adapters?
*in conjunction with adapters?

Revision as of 13:04, 17 May 2013

Document History

  • April 26, 2013 - Initial Draft



public class Root {
	public String name;
	public List<Thing> things;
public class Thing {
	public String thingName;
	public String thingValue;
Root r = new Root();
r.name = "theRootName";
r.things = new ArrayList<Thing>();
Thing thing1 = new Thing();
thing1.thingName = "thinga";
thing1.thingValue = "thingavalue";
Thing thing2 = new Thing();
thing2.thingName = "thingb";
thing2.thingValue = "thingbvalue";
Thing thing3 = new Thing();
thing3.thingName = "thingc";
thing3.thingValue = "thingcvalue";
marshaller.marshal(r, System.out)
marshaller.marshal(r, System.out)


The following annotation will be added

@Target({METHOD, FIELD})
public @interface XmlVariableNode {
    String value() default "##default";
    Class type() default DEFAULT.class;   
    static final class DEFAULT {}
    boolean attribute() default false;

External Bindings

     <xs:element name="xml-variable-node" substitutionGroup="java-attribute">
                <xs:extension base="java-attribute">
                        <xs:element ref="xml-access-methods" minOccurs="0" />
                        <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
                        <xs:element ref="xml-element-wrapper" minOccurs="0"/>
                        <xs:element ref="xml-properties" minOccurs="0" />
                    <xs:attribute name="xml-path" type="xs:string" />
                    <xs:attribute name="read-only" type="xs:boolean" default="false" />
                    <xs:attribute name="write-only" type="xs:boolean" default="false" />
                    <xs:attribute name="container-type" type="xs:string" default="##default" />
                    <xs:attribute name="type" type="xs:string" default="##default" />
                    <xs:attribute name="isAttribute" type="xs:boolean" default="false" />
                    <xs:attribute name="java-variable-attribute" type="xs:string"  />
                    <xs:attribute name="nillable" type="xs:boolean" default="false" />
                    <xs:attribute name="required" type="xs:boolean" default="false" />
 <?xml version="1.0" encoding="US-ASCII"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
		<java-type name="org.eclipse.persistence.testing.jaxb.xmlvariablenode.RootNoAnnotations">
            <xml-root-element name="root" />
                <xml-variable-node java-attribute="things" java-variable-attribute="thingName"/>


2 new mappings will be created XMLVariableXPathObjectMapping and XMLVariableXPathCollectionMapping it will extend the CompositeMappings

This annotation only makes sense when the referenced type is a complex thing. An exception will be thrown if this annotation is used on a simple object or List of simple things.

For Schema generation when this is present an xs:any will be added to the xsd


Since this makes use of the any logic during unmarshal and MOXy only handles one Any mapping on a class if a class makes use of the XmlVariableNode annotation then that class can not have XmlAnyElement annotations or any other variables that would cause AnyObject or AnyCollection mappings to be created. Potential future considerations would be to allow multiple XmlVariableNode annotations on the same object with some type of regular expression/pattern to differentiate them.


  • inheritance
  • List<Object>
  • don`t write out that property itself as nested if it is the variable field - currently need to mark that property as transient.
  • in conjunction with adapters?
  • elementwrapper
  • schemagen
  • Binder
  • isnil nullpolicy
  • map
  • map <a,b> doesn't automatically pull in B