我尝试使用简化插件来简化生成的代码。我有一个定义的类型:
<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>
但它不起作用,因为它会导致以下错误:
compiler was unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings.
我完全使用了配置,我还有其他可以工作的 Jaxb 插件,所以我不太确定,插件是否损坏或其他什么? 有没有人设法让它运行?
注释
应该放在 Element 标记下,让编译器理解它是针对该特定元素的。
尝试以下操作并告诉我它是否有效。
<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>