简体   繁体   English

JAXB为XSD的复杂类型和元素引用两次生成类

[英]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). 我的场景: complexType和一个别名为此complexType的元素 (它们具有不同的名称)。 Both of them has annotation documentation . 他们两个都有注释 文档

This results in Status.java and StatusType.java with the exact same content. 这将导致Status.java和StatusType.java具有完全相同的内容。 (Only one of them with XmlRootElement) (只有其中之一带有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! 但是,当我仅从元素中删除注释文档时,我只会得到一个 生成的 Java ,这实际上是预期的结果! 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. :)我想使XSD保持不变,因为它是由其他供应商提供的,不是由我们公司开发的,但是我不希望类重复。

Thanks! 谢谢!

We found two instances of typos as follows in the XSD: 我们在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. 因此,notification-doc元素处于同一级别的元素,而不是在元素内部。 After fixing them JAXB build was success. 修复它们后,JAXB构建成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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