如何使用外部绑定文件覆盖 JAXB 中的默认名称?
我有一个看起来像这样的元素。
<xsd:element name="container">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="navmap"/>
<xsd:element ref="keymap" />
<xsd:element ref="container" />
<xsd:element ref="ad" />
<xsd:element ref="button" />
<xsd:element ref="checkbox" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
以下是为此元素创建的默认代码。
@XmlElements({
@XmlElement(name = "navmap", type = Navmap.class),
@XmlElement(name = "keymap", type = Keymap.class),
@XmlElement(name = "container", type = Container.class),
@XmlElement(name = "ad", type = Ad.class),
@XmlElement(name = "button", type = Button.class),
@XmlElement(name = "checkbox", type = Checkbox.class),
})
protected List<Object> navmapOrKeymapOrContainer;
我的问题是我需要在我的 .xjb
绑定文件中放入什么来更改默认生成的名称 navmapOrKeymapOrContainer
其他事情,比如 孩子
?
I have an element that looks something like this.
<xsd:element name="container">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="navmap"/>
<xsd:element ref="keymap" />
<xsd:element ref="container" />
<xsd:element ref="ad" />
<xsd:element ref="button" />
<xsd:element ref="checkbox" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
Here is the default code that gets created for this element.
@XmlElements({
@XmlElement(name = "navmap", type = Navmap.class),
@XmlElement(name = "keymap", type = Keymap.class),
@XmlElement(name = "container", type = Container.class),
@XmlElement(name = "ad", type = Ad.class),
@XmlElement(name = "button", type = Button.class),
@XmlElement(name = "checkbox", type = Checkbox.class),
})
protected List<Object> navmapOrKeymapOrContainer;
My question is What do I need to put in my .xjb
bindings file to change the default generated name from navmapOrKeymapOrContainer
to something else like children
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
示例:
在您的绑定文件中修改此内容即可。请参阅此处以供参考。
清单 11 揭示了这个秘密:
Example:
Adapt this in your binding file and it will do. See here for reference.
Listing 11 tells the secret: