hudi
hudi

Reputation: 16525

Why JAXB inheritance not working in static class

I have xsd:

<xs:complexType name="AppService1ResponseType">
    <xs:complexContent>
        <xs:extension base="AppResponseType">
            <xs:sequence minOccurs="0">
                <xs:element name="Person" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="Element1" type="xs:string" nillable="true"
                                minOccurs="0" /> ....

which generate static class inside AppService1ResponseType

public static class Osoba
    implements Serializable

and binding.xml:

    <jaxb:bindings node="//xs:complexType[@name='AppService1ResponseType']/xs:complexContent/xs:extension/xs:sequence/xs:element[@name='Person']">
        <inheritance:implements>com.app.PersonI</inheritance:implements>
    </jaxb:bindings>

which should implement interface to this generated class. I also tried another XPath or just element[@name='Person'] but with no success. When I tried another non static class like AppService1ResponseType then inheritace works OK. Is there some workaround how to solve this issue ?

Upvotes: 2

Views: 156

Answers (1)

hudi
hudi

Reputation: 16525

ok. I found there was error in xpath which should end with /xs:complexType

so the correct xpath in binding is:

<jaxb:bindings node="//xs:complexType[@name='AppService1ResponseType']/xs:complexContent/xs:extension/xs:sequence/xs:element[@name='Person']/xs:complexType">
    <inheritance:implements>com.app.PersonI</inheritance:implements>
</jaxb:bindings>

Upvotes: 1

Related Questions