简体   繁体   English

Jaxb简化插件

[英]Jaxb Simplify Plugin

i try to use the simplify plugin to simplify the generated code. 我尝试使用简化插件来简化生成的代码。 I have a defined type: 我有一个定义的类型:

<xsd:complexType name="typeWithReferencesProperty">
        <xsd:choice maxOccurs="unbounded">
        <xsd:annotation>
                <xsd:appinfo>
                    <simplify:as-element-property/>
                </xsd:appinfo>
            </xsd:annotation>
            <xsd:element name="a" type="AttributeValueIntegerType"/>
            <xsd:element name="b" type="AttributeValueIntegerType"/>
        </xsd:choice> 
    </xsd:complexType>

but it does not work, as it results in the following error: 但它不起作用,因为它导致以下错误:

compiler was unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings.

i used exactly the configuration, i also have other jaxb plugins which work, so i am not quite sure, if the plugin is broken or something? 我完全使用了配置,我也有其他可以工作的jaxb插件,所以我不确定,如果该插件坏了还是什么? has anybody managed to get this running? 有没有人设法使它运行?

Annotation should come under Element tag to let the compiler understand that it is for that particular element. 注释应位于Element标记下,以使编译器了解它是针对特定元素的。

Try the following and tell me if it works. 请尝试以下操作,并告诉我是否可行。

<xs:complexType name="typeWithReferencesProperty">
    <xs:choice maxOccurs="unbounded">
        <xs:element name="a" type="someType">
            <xs:annotation>
                <xs:appinfo>
                    <simplify:as-element-property/>
                </xs:appinfo>
            </xs:annotation>
        </xs:element>
        <xs:element name="b" type="someType">
                              <xs:annotation>
                <xs:appinfo>
                    <simplify:as-element-property/>
                </xs:appinfo>
            </xs:annotation>
    </xs:choice> 
</xs:complexType>

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

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