从 XSD 模式生成 Java,两个属性具有相同的名称但不同的命名空间

Generating Java from XSD schemas, two attributes have the same name but different namespaces

尝试从 XSD 模式生成 Java 代码,其中 complexType 包含两个名称相同但命名空间不同的属性。

<xsd:complexType name="CT_ImageData">
  <xsd:attribute ref="o:href"/>
  <xsd:attribute ref="r:href"/>
</xsd:complexType>

xjc 说:[ERROR] Property "Href" is already defined. Use <jaxb:property> to resolve this conflict.

尝试过自定义绑定:

    <bindings node="//xs:complexType[@name='CT_ImageData']">
        <bindings node=".//xs:attribute[@name='href']">
            <property name="originalHref"/>
        </bindings>
    </bindings>

但是我的绑定没有选择属性:[ERROR] XPath evaluation of ".//xs:attribute[@name='href']" results in empty target node

如何在我的 bindings 中只定位 o 命名空间的 href 属性?

尝试.//xs:attribute[@ref='o:href']
它只是 XPath,其背后没有模式解释。因此,请确保您的 XPath 实际上指向现有节点。