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.
Difference between revisions of "EclipseLink/DesignDocs/293925/MOXyExtensions/XmlAnyObjectMapping"
(→Requirements) |
|||
Line 3: | Line 3: | ||
== Requirements == | == Requirements == | ||
− | Provide support for XML any object mapping configuration via XML metadata file. | + | Provide support for XML any object mapping configuration via XML metadata file. |
+ | |||
+ | The following should be configurable: | ||
+ | * [http://wiki.eclipse.org/EclipseLink/DesignDocs/293925/MOXyExtensions#Path-based_mapping_support Path-based mappings] | ||
+ | * [http://wiki.eclipse.org/EclipseLink/DesignDocs/293925/MOXyExtensions#Read_only Read only] | ||
+ | * [http://wiki.eclipse.org/EclipseLink/DesignDocs/293925/MOXyExtensions#Write_only Write only] | ||
+ | * [http://wiki.eclipse.org/EclipseLink/DesignDocs/293925/MOXyExtensions#Get.2FSet_Method_Names Get/set method names] | ||
+ | |||
+ | == Design == | ||
+ | === Basic XML any object mapping support === | ||
+ | We will extend our current <code>xml-any-element</code> support to allow any mapping configuration. We will need to modify the XSD such that <code>xml-path</code>, <code>xml-access-methods</code>, <code>read-only</code>, etc. can be set on <code>xml-any-element</code>. For example, the following XML metadata snippet would be used to setup an any object mapping for 'stuff': | ||
+ | <source lang="xml"> | ||
+ | <xml-any-element java-attribute="stuff" /> | ||
+ | </source> | ||
+ | |||
+ | If <code>stuff</code> was to be mapped to <code>junk/stuff</code>, then the following would be used: | ||
+ | <source lang="xml"> | ||
+ | <xml-any-element java-attribute="stuff" xml-path="junk/stuff" /> | ||
+ | </source> | ||
+ | |||
+ | == Example: == | ||
+ | The following example will demonstrate how to configure XML any object mappings via XML metadata by using <code>xml-any-element</code>. | ||
+ | |||
+ | === org.example.Employee.java === | ||
+ | <source lang="java"> | ||
+ | package org.example; | ||
+ | |||
+ | public class Employee { | ||
+ | public Object stuff; | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | === Deployment XML === | ||
+ | <source lang="xml"> | ||
+ | </source> | ||
+ | |||
+ | === XML Instance Document === | ||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | <employee xmlns:s="http://www.example.com/stuff"> | ||
+ | <things> | ||
+ | <junk> | ||
+ | <s:stuff>Some Stuff</s:stuff> | ||
+ | </junk> | ||
+ | </things> | ||
+ | </employee> | ||
+ | </source> | ||
+ | |||
+ | |||
+ | === org/example/eclipselink-oxm.xml === | ||
+ | This XML file demonstrates configuring XML any object mappings on the "org.example.Employee" class. | ||
+ | <source lang="xml"> | ||
+ | <?xml version="1.0" encoding="US-ASCII"?> | ||
+ | <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"> | ||
+ | <xml-schema> | ||
+ | <xml-ns namespace-uri="http://www.example.com/stuff" prefix="s"/> | ||
+ | </xml-schema> | ||
+ | <java-types> | ||
+ | <java-type name="org.example.Employee"> | ||
+ | <xml-root-element name="employee" /> | ||
+ | <java-attributes> | ||
+ | <xml-any-element java-attribute="stuff" xml-path="things/junk/s:stuff" xml-mixed="true" /> | ||
+ | </java-attributes> | ||
+ | </java-type> | ||
+ | </java-types> | ||
+ | </xml-bindings> | ||
+ | </source> | ||
== Open Issues == | == Open Issues == |
Revision as of 15:58, 30 March 2010
XMLAnyObjectMapping
Requirements
Provide support for XML any object mapping configuration via XML metadata file.
The following should be configurable:
Design
Basic XML any object mapping support
We will extend our current xml-any-element
support to allow any mapping configuration. We will need to modify the XSD such that xml-path
, xml-access-methods
, read-only
, etc. can be set on xml-any-element
. For example, the following XML metadata snippet would be used to setup an any object mapping for 'stuff':
<xml-any-element java-attribute="stuff" />
If stuff
was to be mapped to junk/stuff
, then the following would be used:
<xml-any-element java-attribute="stuff" xml-path="junk/stuff" />
Example:
The following example will demonstrate how to configure XML any object mappings via XML metadata by using xml-any-element
.
org.example.Employee.java
package org.example; public class Employee { public Object stuff; }
Deployment XML
XML Instance Document
<?xml version="1.0" encoding="UTF-8"?> <employee xmlns:s="http://www.example.com/stuff"> <things> <junk> <s:stuff>Some Stuff</s:stuff> </junk> </things> </employee>
org/example/eclipselink-oxm.xml
This XML file demonstrates configuring XML any object 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"> <xml-schema> <xml-ns namespace-uri="http://www.example.com/stuff" prefix="s"/> </xml-schema> <java-types> <java-type name="org.example.Employee"> <xml-root-element name="employee" /> <java-attributes> <xml-any-element java-attribute="stuff" xml-path="things/junk/s:stuff" xml-mixed="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 |
---|---|---|