简体   繁体   中英

JAXB generates class twice for complextype and element ref from XSD

My scenario: complexType and an element that aliases this complexType (they have different name). Both of them has annotation documentation .

This results in Status.java and StatusType.java with the exact same content. (Only one of them with XmlRootElement)

<xs:element name="Status" type="Status_Type">
    <xs:annotation>
        <xs:documentation xml:lang="en">Some docs.</xs:documentation>
    </xs:annotation>
</xs:element>

<xs:complexType name="Status_Type">
    <xs:annotation>
        <xs:documentation xml:lang="en">Some docs.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
        <!-- some elements -->
    </xs:sequence>
    <xs:attribute name="Id" type="xs:ID"/>
</xs:complexType>

However, when I remove only the annotation documentation from element, I only get one generated Java class which is actually the expected result! How can I configure this behavior? :) I want to keep the XSD unchanged as is because it us supplied from a different vendor, not developed by our company, but I don't want class duplicates.

Thanks!

We found two instances of typos as follows in the XSD:

<xs:element name="SomeElement" type="Boolean_Type"/>
<xs:annotation>
    <xs:documentation xml:lang="hu">SomeDocs</xs:documentation>
</xs:annotation>
<xs:element name="SomeOtherElement" type="Identifier_Type"/>

So annotation-doc element was at the same level of elements, not inside them. After fixing them JAXB build was success.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM