我一直在尝试解析xsd文件,以便能够在本地生成jaxb文件。为了做到这一点,我在linux上使用xjc
命令,而不使用命令本身的任何选项。
但即使我用它也基本上是:
xjc SpaceSystem.xsd
给出如下错误:
ogurdogan@ogurdogan:~/Documents/XTCE/XJC Test$ xjc SpaceSystem.xsd parsing a schema... [ERROR] The value of attribute "value" associated with an element type "enumeration" must not contain the '<' character. line 4399 of file:/home/ogurdogan/Documents/XTCE/XJC%20Test/SpaceSystem.xsd
错误发生的定义可以在下面第11行看到。
<simpleType name="ComparisonOperatorsType">
<annotation>
<documentation xml:lang="en">Operators to use when testing a boolean condition for a validity check</documentation>
</annotation>
<restriction base="string">
<enumeration value="=="/>
<enumeration value="!="/>
<enumeration value="<"/>
<enumeration value="<="/>
<enumeration value=">"/>
<enumeration value=">="/>
</restriction>
</simpleType>
即使我一直在使用的xsd模式在这里是一个非常通用和正式的模式,它也会产生如上所示的错误。因为它是一个默认模式,不应该被修改,我不知道我需要做什么。
经过一些尝试,我也尝试使用xjc
的选项,如:
- nv
- 扩展
但结果是一样的…
有什么问题吗?
当我查看链接模式的来源(例如view-source:https://www.omg.org/spec/XTCE/20180204/SpaceSystem.xsd in Chrome)在4397行和以下我发现
<simpleType name="ComparisonOperatorsType">
<annotation>
<documentation xml:lang="en">Operators to use when testing a boolean condition for a validity check</documentation>
</annotation>
<restriction base="string">
<enumeration value="=="/>
<enumeration value="!="/>
<enumeration value="<"/>
<enumeration value="<="/>
<enumeration value=">"/>
<enumeration value=">="/>
</restriction>
</simpleType>
这与您所显示的完全不同,实际上任何XML文档都不能在属性值中有未转义的<
符号。
我不知道xjc
,但我猜它不会抱怨你以原始形式保存链接到的真实模式,有人可能错误地保存了浏览器的"漂亮的打印";使用select all->复制→粘贴,即已知不保留原始标记。