[英]jaxb2 simplify plugin elements not simplified
我試圖使用mave-jaxb2插件和jaxb2-basics簡化插件將XSD轉換為JAXB類。
pom.xml中的配置在這篇文章中可用
sample.xsd(復雜選擇類型)
<xs:complexType name="doclist">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="document1" type="type1">
<xs:annotation>
<xs:appinfo>
<simplify:as-reference-property/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="document2" type="type2">
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="heading" type="xs:string" />
</xs:complexType>
但是,生成的JAXB類具有aOrB引用。
@XmlElements({
@XmlElement(name = "document1", type = Type1.class),
@XmlElement(name = "document2", type = Type2.class)
})
protected List<Object> document1OrDocument2;
您具有elements
屬性,因此必須將注釋放置在xs:choice
,而不是xs:element
。 請參閱文檔 。
而且您很可能想使用<simplify:as-element-property/>
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.