我要解析这个ETSI REM schema。如你所见,在第82行,他们有:
xs:element ref="xades:Any" minOccurs="0"/
这使得jaxb编译器变得疯狂,因为它们引用已经包含Any的模式(如Xades),并且在第166行和第212行中它们定义了其他元素,如
xs:element name="TransactionLog" type="xades:AnyType"/
我将架构编译为:
xjc TS02640v1_3.xsd -d test1 -p test -b binTS1.xjb -extension
文件位于:
<jxb:bindings version="2.1"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jxb:extensionBindingPrefixes="xjc">
<jxb:globalBindings>
<xjc:simple/>
</jxb:globalBindings>
<jxb:bindings schemaLocation="TS02640v1_3.xsd">
<jxb:schemaBindings>
<jxb:package name="eu.esens.abb.nonrep.etsi.rem"/>
</jxb:schemaBindings>
<jxb:bindings node="//xs:complexType[@name='PostalAddressType']">
<jxb:class name="PostalAddressTypeREM"/>
</jxb:bindings>
<jxb:bindings node="//xs:complexType[@name='ExtensionType']">
<jxb:class name="ExtensionTypeREM"/>
</jxb:bindings>
<!--jxb:bindings node="//xs:complexType[@name='EntityDetailsType']/xs:sequence/xs:element[@name='AnyType']">
<jxb:class name="AnyTypeREM"/>
</jxb:bindings-->
</jxb:bindings>
</jxb:bindings>
编译器说:
compiling a schema...
[ERROR] A class/interface with the same name "eu.esens.abb.nonrep.etsi.rem.AnyType" is already in use. Use a class customization to resolve this conflict.
line 8 of http://uri.etsi.org/01903/v1.3.2/XAdES.xsd
[ERROR] (Relevant to above error) another "AnyType" is generated from here.
line 76 of http://uri.etsi.org/02231/v3.1.2/ts_102231v030102_xsd.xsd
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 8 of http://uri.etsi.org/01903/v1.3.2/XAdES.xsd
[ERROR] (Related to above error) This is the other declaration.
line 76 of http://uri.etsi.org/02231/v3.1.2/ts_102231v030102_xsd.xsd
Failed to produce code.
我也尝试了内联(在xsd中)绑定,结果相同。
任何帮助表示赞赏!
答案 0 :(得分:0)
问题清楚地显示在日志中。类型AnyType
在这两个引用的模式中声明
http://uri.etsi.org/02231/v3.1.2/ts_102231v030102_xsd.xsd
http://uri.etsi.org/01903/v1.3.2/XAdES.xsd
您需要使用schemalocation
<jxb:bindings schemaLocation="ts_102231v030102_xsd.xsd">
jxb:bindings node="//xs:complexType[@name='AnyType']">
<jxb:class name="AnyTypeREM"/>
</jxb:bindings
</jxb:bindings>