(请参阅下面有关此问题来源的更新)
尝试使用任何类型的外部绑定文件运行xjc
时出现任何问题。
这是我尝试使用的绑定文件的副本:
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:pd="http://chubb.com/cpi/polsvc/xmlobj"
jxb:extensionBindingPrefixes="xjc"
version="2.1">
<jxb:bindings schemaLocation="your-schema.xsd">
<jxb:bindings node="//xs:complexType[@name='AddBankVaultRplyType']">
</jxb:bindings>
</jxb:bindings>
我知道它没有做任何事情,只是想尝试一个简单的例子来运行。 我正在运行以下命令:
xjc -extension -b src/main/resources/bindings/cXML.xjb -dtd -d tmp src/main/resources/dtds/cXML.dtd -verbose
我收到以下错误:
parsing a schema...
[ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
line 7 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb
[ERROR] cvc-elt.1: Cannot find the declaration of element 'jxb:bindings'.
line 7 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb
[ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
line 8 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb
[ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
line 9 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb
Failed to parse a schema.
无论我在jaxb项目的绑定文件中放入什么,它总是以Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"
类型错误消息的形式存档。
我在这里遗漏了什么吗?这些论文看起来应该是非常直接的,我不知道为什么它会给我带来问题。
XJC版本:
xjc -version
xjc 2.2.8-b130911.1802
谢谢!
更新
xjb文件的最初目的是修复DTD的一些问题。特别是命名冲突,例如:
[ERROR] Property "Name" is already defined. Use <jaxb:property> to resolve this conflict.
答案 0 :(得分:1)
这是因为你正在编译DTD。这是一种非常不同类型的动物,正常绑定不适用于DTD。
这是编译DTD的sample project。 binding如下所示:
<?xml version="1.0"?>
<xml-java-binding-schema>
<options package="org.jvnet.hyperjaxb3.hibernate.mapping"/>
<element name="hibernate-mapping" type="class"/>
<element name="class" type="class" class="Clazz">
<attribute name="subselect" property="SubselectAttribute"/>
</element>
<element name="typedef" type="class">
<attribute name="class" property="Clazz"/>
</element>
<element name="import" type="class">
<attribute name="class" property="Clazz"/>
</element>
<element name="composite-id" type="class">
<attribute name="class" property="Clazz"/>
</element>
...
</xml-java-binding-schema>