I have a Parent
and a Child
class.
A House
class has a field of type Parent
which can refer to a Child
object. I need to map it to XML using Eclipse Moxy.
Its xsd would be something like:
<xs:complexType name="Parent" abstract="true">
...other fields...
<xs:complexType name="Child" >
<xs:extension base="Parent">
...other fields...
<xs:element name="child" type="Child" substitutionGroup="parent" />
<xs:element name="parent" type="Parent" abstract="true" />
<xs:complexType name="House">
<xs:element ref="parent"/>
House class contains a JAXBElement to point to Parent:
@XmlElementRef(name = "parent", namespace = "abc", type = JAXBElement.class)
protected JAXBElement<? extends Parent> parent;
How do I map House
class through House.oxm.xml file so this polymorphic mapping works correctly?
<java-type name="House" xml-accessor-type="NONE">
<java-attributes>
<xml-element-ref java-attribute="?????????"/>
I tried using '@' in the mapping but it doesn't work - it just adds the reference String (@Parent) of the object to XML.