【发布时间】:2018-05-02 16:54:38
【问题描述】:
我正在尝试使用我不维护的 xsd 上的 jxb 外部绑定来消除“元素“___”出现在多个属性中”。
我可以使用以下方法修改 XSD:
<xs:complexType name="credit">
<xs:sequence>
<xs:element .../>
<xs:element name="link" type="link" minOccurs="0" maxOccurs="unbounded">
<xs:annotation> <xs:appinfo> <jxb:property name="linkElement"/> </xs:appinfo> </xs:annotation>
</xs:element>
<xs:choice>
<xs:sequence>
...
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="link" type="link" minOccurs="0" maxOccurs="unbounded"/>
...
</xs:sequence>
</xs:sequence>
</xs:choice>
</xs:sequence>
...
创建Link类型的序列linkElement和选择序列:
@XmlElement(name = "link")
protected List<Link> linkElement;
...
@XmlElements({
@XmlElement(name = "link", type = Link.class),
...
})
protected List<Object> linkAndBookmarkAndCreditWords;
但是当我尝试使用 JAXB 外部绑定文件时:
<jxb:bindings node="//xs:complexType[@name='credit']//xs:sequence//xs:element[@name='link']" >
<jxb:property name="linkElement" />
</jxb:bindings>
我得到错误:
[ERROR] XPath evaluation of "...[@name='link']" results in too many (2) target nodes
我如何才能像在内部绑定中那样只区分第一个“链接”节点?
【问题讨论】:
标签: jaxb