Jaxb Simplify Plugin

571 views Asked by At

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? has anybody managed to get this running?

1

There are 1 answers

1
Harish Raj On

Annotation should come under Element tag to let the compiler understand that it is for that particular 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>