I have a xsd file (yahoo.xsd) where I import another xsd file like this:
<xs:import schemaLocation="stock.xsd"/>
<xs:attribute name="lang" type="xs:NCName"/>
The stock.xsd looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng">
<xs:import namespace="http://www.yahooapis.com/v1/base.rng" schemaLocation="yahoo.xsd"/>
<xs:element name="quote">
<xs:complexType>
<xs:sequence>
<xs:element ref="Symbol"/>
</xs:sequence>
<xs:attribute name="symbol" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="Symbol" type="xs:NCName"/>
</xs:schema>
When I am compiling with xjc I am getting the following error message:
[ERROR] Property "Symbol" is already defined. Use <jaxb:property> to resolve this conflict.
I basically found the solution for this here on SO (JAXB Compiling Issue - [ERROR] Property "Any" is already defined) but I can't get it to work. I am guessing my XPath is wrong.
This is the binding file I am using:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.1">
<bindings schemaLocation="yahoo.xsd" version="1.0" >
<!-- rename the value element -->
<bindings node="//xs:element[@name='quote']/xs:complexType/xs:sequence/xs:element[@ref='Symbol']">
<property name="SymbolAttribute"/>
</bindings>
</bindings>
If I am now compiling with xjc -b it says that the XPath evaluation results in an empty target node.
I probably have to rename the Symbol definition and then the ref as well? how to do this automatically?