jaxb2-basics and inheritance

336 views Asked by At

I am successfully using jaxb2-basics for inheritance support. I am trying to add some more inheritance but cannot figure out how to do that in a specific situation. I have this XSD fragment:

<xsd:complexType name="hbm-any-mapping">
    <xsd:element name="discriminator">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="type" type="xsd:string" minOccurs="0" maxOccurs="1" />
                <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="1" />
                <xsd:element name="mapping" type="orm:hbm-any-discriminator-value-mapping" minOccurs="1" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:complexType>

In my XJC binding I had this originally, and it works:

<bindings node="//xsd:complexType[@name='hbm-any-mapping']">
    <inheritance:implements>...</inheritance:implements>
</bindings>

<bindings node="//xsd:complexType[@name='hbm-any-discriminator-value-mapping']">
    <inheritance:implements>...</inheritance:implements>
    <property name="CorrespondingEntityName"/>
    <bindings node=".//xsd:attribute[@name='value']">
       <property name="DiscriminatorValue"/>
    </bindings>
</bindings>

Now I am trying to apply interfaces to the mapping for discriminator and its sub-nodes. I tried this:

<bindings node="//xsd:complexType[@name='hbm-any-mapping']">
    <inheritance:implements>...</inheritance:implements>

    <bindings node=".//xsd:element[@name='discriminator']">
        <inheritance:implements>...</inheritance:implements>

        <bindings node=".//xsd:element[@name='mapping']">
            <inheritance:implements>...</inheritance:implements>
            <property name="valueMappings"/>
        </bindings>

    </bindings>
</bindings>

But that does not work. I don't get an error, but the inheritance is not applied for discriminator nor is the property naming for mapping.

Any pointers?

Thanks!

1

There are 1 answers

0
Steve Ebersole On

I broke them out into separate, named complexType definitions and applied the inheritance by selecting those complexTypes. It works.