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/Development/2.1/DynamicMOXy/296967/Documentation"

Line 6: Line 6:
  
 
= Step 1: Creating a DynamicJAXBContext =
 
= Step 1: Creating a DynamicJAXBContext =
 +
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<xs:schema targetNamespace="myNamespace" xmlns:myns="myNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"
 +
    attributeFormDefault="qualified" elementFormDefault="qualified">
 +
 +
    <xs:element name="data">
 +
        <xs:complexType>
 +
            <xs:sequence>
 +
                <xs:element name="person" type="myns:person"/>
 +
                <xs:element name="company" type="myns:company"/>
 +
            </xs:sequence>
 +
        </xs:complexType>
 +
    </xs:element>
 +
 +
    <xs:complexType name="person">
 +
        <xs:sequence>
 +
            <xs:element name="name" type="xs:string"/>
 +
            <xs:element name="company" type="xs:IDREF"/>
 +
        </xs:sequence>
 +
    </xs:complexType>
 +
 +
    <xs:complexType name="company">
 +
        <xs:sequence>
 +
            <xs:element name="name" type="xs:string"/>
 +
            <xs:element name="address" type="xs:string"/>
 +
        </xs:sequence>
 +
        <xs:attribute name="id" type="xs:ID"/>
 +
    </xs:complexType>
 +
 +
</xs:schema>
 +
</source>

Revision as of 14:24, 27 April 2010

Dynamic MOXy - JAXB with Dynamically Generated Java Classes

EclipseLink Dynamic MOXy introduces a new concept in JAXB development - the freedom to bootstrap a JAXBContext from a variety of metadata sources and use conventional JAXB APIs to marshal and unmarshal data, all without having actual compiled Java class files on the classpath. This gives the user the flexibility to alter their metadata at any time, and not have to worry about updating and recompiling the previously-generated Java source code.

Step 1: Creating a DynamicJAXBContext

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="myNamespace" xmlns:myns="myNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    attributeFormDefault="qualified" elementFormDefault="qualified">
 
    <xs:element name="data">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="person" type="myns:person"/>
                <xs:element name="company" type="myns:company"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
 
    <xs:complexType name="person">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="company" type="xs:IDREF"/>
        </xs:sequence>
    </xs:complexType>
 
    <xs:complexType name="company">
        <xs:sequence>
            <xs:element name="name" type="xs:string"/>
            <xs:element name="address" type="xs:string"/>
        </xs:sequence>
        <xs:attribute name="id" type="xs:ID"/>
    </xs:complexType>
 
</xs:schema>

Back to the top