我有下面这个来自供应商的 XSD
片段,我不能改变它的规范:
<xsd:element name="navmap">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="navitem"/>
<xsd:element ref="debug"/>
</xsd:choice>
<xsd:attribute name="focus" type="xsd:string" use="optional"/>
</xsd:complexType>
</xsd:element>
现在没有进行定制,它将生成以下代码
@XmlElements({
@XmlElement(name = "navitem", type = Navitem.class),
@XmlElement(name = "debug", type = Debug.class)
})
protected List<Object> navitemOrDebug;
我希望它能为每种类型生成一个单独的列表,就像下面这样。
@XmlElements({
@XmlElement(name = "navitem", type = Navitem.class)
})
protected List<Navitem> navitems;
@XmlElements({
@XmlElement(name = "debug", type = Debug.class)
})
protected List<Debug> debugs;
我在我的.xjb
文件中有以下内容,它可以重命名整个List
,但我无法弄清如何将它们分开。
<jxb:bindings node="//xsd:element[@name='navmap']//xsd:complexType//xsd:choice">
<jxb:property name="contents" />
</jxb:bindings>
我该如何指定在外部的.xjb绑定文件中为每个类型分别创建单独的List或Set?
如果无法这样做,我该如何在.xsd文件中添加jaxb:annotation来为每个类型指定单独的List或Set?
在这种情况下,顺序不重要。
注意:我更喜欢使用外部的.xjb解决方案,我不想针对供应商提供的每个新版本自定义xsd进行差异比较,因为它们太多了。