Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be 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/Examples/MOXy/EclipseLink-OXM.XML"

(How to use eclipselink-orm.xml)
(How to use eclipselink-orm.xml)
Line 12: Line 12:
 
<source lang="xml">
 
<source lang="xml">
 
<?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"
 +
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_1.xsd"
 +
        version="2.1">
 
     <java-types>
 
     <java-types>
 
         <java-type name="mynamespace.Person">
 
         <java-type name="mynamespace.Person">
 
             <xml-root-element name="person"/>
 
             <xml-root-element name="person"/>
 
             <java-attributes>
 
             <java-attributes>
                 <xml-element java-attribute="type" xml-path="bloodType/text()"/>
+
                 <xml-element java-attribute="name" xml-path="text()"/>
 
             </java-attributes>
 
             </java-attributes>
 
         </java-type>
 
         </java-type>

Revision as of 21:35, 15 June 2010

EclipseLink supports the use of JAXB with externalized mapping files. These mapping files support specifying the Object-XML binding of JAXB 2.2 annotations plus many of the advanced mapping and configuration options provided by EclipseLink MOXy.

How to use eclipselink-orm.xml

In order to specify the mappings between domain objects and an XSD an application must provide:

  1. An XML mapping file per package
  2. A JAXB.properties file specifying EclipseLink as the JAXB implementation

Example Mapping File: /model/eclipselink-oxm.xml

<?xml version="1.0" encoding="US-ASCII"?>
<xml-bindings 
        xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_1.xsd"
        version="2.1">
    <java-types>
        <java-type name="mynamespace.Person">
            <xml-root-element name="person"/>
            <java-attributes>
                <xml-element java-attribute="name" xml-path="text()"/>
            </java-attributes>
        </java-type>
    </java-types>
</xml-bindings>

Specifying the EclipseLink MOXy Runtime

To specify the EclipseLink MOXy (JAXB) runtime should be used you need to add a file called jaxb.properties in the same package as the domain classes with the following entry.

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

Specifying the mapping files

In order to configure EclipseLink MOXy to use the mapping files ...

Back to the top