我有一個XSD文件(yahoo.xsd),我導入另一個XSD文件是這樣的:符號已被定義。使用JAXB屬性來解決衝突
<xs:import schemaLocation="stock.xsd"/>
<xs:attribute name="lang" type="xs:NCName"/>
的stock.xsd看起來是這樣的:
<?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>
當我使用xjc編譯時,我收到以下錯誤消息:
[錯誤]屬性「符號」已定義。使用< jaxb:property>來解決此衝突。
我基本上在SO(JAXB Compiling Issue - [ERROR] Property "Any" is already defined)上找到了這個解決方案,但是我無法使它工作。我猜我的XPath是錯誤的。
這是我使用的綁定文件:
<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>
如果我現在XJC編譯-b它說,XPath的評價結果在一個空的目標節點。
我可能必須重命名符號定義,然後重新命名?如何自動做到這一點?
您是否嘗試添加模式作爲基節點?例如。? –
2013-03-04 03:36:14