XJC annotation issue

606 views Asked by At

I am trying add deprecated annotation on my xjb generated stubs.

 <jaxb:bindings schemaLocation="../../../../../server/target/schemas/schema2.xsd">
      <jaxb:bindings node="xs:complexType[@name='someForms']/xs:all/xs:element[@name='detailsForm']">
          <annox:annotate target="getter">@java.lang.Deprecated</annox:annotate>
  </jaxb:bindings>
</jaxb:bindings>

It does not fail but does not put xml attribute on the field. This is how xsd looks -

<xs:complexType name="approvalForms">
    <xs:all>
       <xs:element name="detailsForm" type="formRef" minOccurs="0"/>
    </xs:all>
</xs:complexType>

But, the following works

<jaxb:bindings schemaLocation="../../../../../server/target/schemas/schema2.xsd">
  <jaxb:bindings node="xs:complexType[@name='someForms']">
     <annox:annotate>
        <annox:annotate annox:class="org.codehaus.jackson.annotate.JsonTypeName"
           value="SomeForm" />
     </annox:annotate>
  </jaxb:bindings>

Am I missing something ? How can I add @Deprecated on getDetailsForm() in stub ?

1

There are 1 answers

0
lexicore On

Syntax actually looks correct. Might be a bug, please file an issue and provide a test case via PR in this project:

I'll take care of it.

By the way, your customization does not match your XSD: someForms vs. approvalForms. This might also be a problem - you may be looking in a wrong class.

Disclaimer: I'm the author.