您好我正在尝试为xjc创建外部绑定XML,但我遇到了2个错误:
[ERROR] A class/interface with the same name "x.x.DaysOfWeek" is already in use. Use a class customization to resolve this conflict.
[ERROR] (Relevant to above error) another "DaysOfWeek" is generated from here.
我错过了什么专业吗?我需要第二双眼睛。感谢
<!-- data.xsd -->
<xs:complexType name="DaysOfWeek">
<xs:sequence>
<xs:element ref="DaysOfWeek"/>
</xs:sequence>
</xs:complexType>
<xs:element name="DaysOfWeek">
<xs:complexType mixed="true">
<xs:attribute name="Type" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
我现在有bindings.xml
<jaxb:bindings version="1.0" xmlns:jaxb="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"
jaxb:extensionBindingPrefixes="xjc">
<jaxb:bindings schemaLocation="data.xsd">
<jaxb:schemaBindings>
<jaxb:package name="net.opengis.kml.v_2_2_0"/>
</jaxb:schemaBindings>
<jaxb:bindings node="xs:complexType[@name='DaysOfWeek']//xs:element[@ref='DaysOfWeek']">
<jaxb:property name="ComplexDaysOfWeek"/>
</jaxb:bindings>
<jaxb:bindings node="xs:element[@name='DaysOfWeek']">
<jaxb:factoryMethod name="ComplexDaysOfWeek"/>
</jaxb:bindings>
</jaxb:bindings>
答案 0 :(得分:0)
您在生成的类上发生了冲突。尝试添加:
<jaxb:bindings node="xs:element[@name='DaysOfWeek']//xs:complexType">
<jaxb:class name="ComplexDaysOfWeekType"/>
</jaxb:bindings>
(也许没有//xs:complexType
,不太确定。)
答案 1 :(得分:0)
使用
解决了该问题<jaxb:bindings schemaLocation="data.xsd" node="/xs:schema">
<jaxb:bindings node="xs:element[@name='DaysOfWeek']">
<jaxb:class name="ComplexDaysOfWeek"/>
</jaxb:bindings>
<jaxb:bindings node="xs:complexType[@name='DaysOfWeek']//xs:element[@ref='DaysOfWeek']">
<jaxb:property name="ComplexDaysOfWeek"/>
</jaxb:bindings>
</jaxb:bindings>