Sam Barnum
Sam Barnum

Reputation: 10714

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

Trying to generate Java code from an XSD schema where a complexType contains two attributes with identical names, but different namespaces.

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

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

Tried custom bindings:

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

But my binding is not selecting the attributes: [ERROR] XPath evaluation of ".//xs:attribute[@name='href']" results in empty target node

How do I target just the o namespaced href attribute in my bindings?

Upvotes: 0

Views: 134

Answers (1)

lexicore
lexicore

Reputation: 43671

Try .//xs:attribute[@ref='o:href'].
It's just XPath there's no schema interpretation behind it. So make sure your XPath actually points to an existing node.

Upvotes: 1

Related Questions