【发布时间】:2017-08-20 20:20:18
【问题描述】:
我有以下 xsd(我只在此处发布相关部分,但命令也针对此摘录运行)
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
<xs:complexType name="OptionType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="name" use="optional"/>
<xs:attribute type="xs:string" name="value" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="ControllableType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:float" name="value" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
我对它运行以下命令:
xjc src/main/resources/session.xsd -p org.myorg.mypackage -d src/main/java/org/myorg/mypackage
我收到以下错误:
[ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
line 39 of jar:file:/usr/lib/jvm/java-8-openjdk-amd64/lib/tools.jar!/com/sun/xml/internal/xsom/impl/parser/datatypes.xsd
[ERROR] The following location is relevant to the above error
line 14 of file:/home/user/project/src/main/resources/session.xsd
[ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
line 39 of jar:file:/usr/lib/jvm/java-8-openjdk-amd64/lib/tools.jar!/com/sun/xml/internal/xsom/impl/parser/datatypes.xsd
[ERROR] The following location is relevant to the above error
line 7 of file:/home/user/project/src/main/resources/session.xsd
Failed to parse a schema.
我在这里读到了一些关于绑定的内容:
Symbol is already defined. Use JAXB property to resolve the conflict
JAXB Compiling Issue - [ERROR] Property "Any" is already defined
但是为什么还需要这个呢? XML 元素名称与属性名称结合,属性不是完全限定和唯一的吗?
如“OptionType.value”或“ControllableType.value”
【问题讨论】:
-
等待Blaise Doughan出现...