0

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!

theBushman
  • 145
  • 12
  • See also: http://stackoverflow.com/questions/16285036/specify-type-for-idref-in-xml-schema – lexicore Nov 11 '14 at 14:48
  • Thanks for the quick reply. I understand how the binding works in the link in the above comment but what if I wanted to reuse the HJIII-53-A object? So in the case of this question how would I reuse the Allocation idRef attribute to be two point to two different references, depending on there usage - either used in XYZ or used in ABC. – theBushman Nov 12 '14 at 05:52
  • This was just a quick pointer, not an answer. I think you also need elements in your example. I'd try to make a superclass/base type for XYZ and ABC and use that type in `idRef`, but I don't have time for the full answer right now. – lexicore Nov 12 '14 at 08:27

0 Answers0