specify type for multiple IDREF attributes in JAXB bindings



Apologies if this is a duplicate question, but I could not find anything for my situation. So here goes:


I have the following in an xsd file:



<xs:complexType name="Allocation">
<xs:annotation>
<xs:documentation>Links its owner to an xs:id.</xs:documentation>
</xs:annotation>
<xs:attribute name="idRef" type="xs:IDREF"/>
</xs:complexType>

<xs:complexType name="XYZ">
<xs:sequence>
<xs:element name="SomeAllocation" type="Allocation"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="ABC">
<xs:sequence>
<xs:element name="SomeAllocation" type="Allocation"/>
</xs:sequence>
</xs:complexType>


I am try to generate fields/getters and setters in java that are of specific types for example XYZ.getSomeAllocation() should return type Object1 and ABC.getSomeAllocation() should return type Object2. The problem I am facing is that xjc is generating one Allocation class and the XYZ and ABC classes with the methods mentioned below returning java.lang.Object types.


Obviously creating to different Allocation types which are then used in the different objects solves the problem but I would like to reuse the object holding the xs:IDREF.


Your help is highly appreciated! Thanks!


No comments:

Post a Comment