2011-10-20 57 views
0

我在构建JAXB绑定方案集时遇到了一些问题,它使我有点慌乱。这是有问题的模式(它可能只是模式之一,在这个特殊的版本):被忽略的Jaxb绑定文件

<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace"> 
<attribute name="lang" type="language"> 
    <annotation> 
     <documentation>In due course, we should install the relevant ISO 2- and 3-letter 
      codes as the enumerated possible values . . .</documentation> 
    </annotation> 
</attribute> 
<attribute name="space" default="preserve"> 
    <simpleType> 
     <restriction base="NCName"> 
      <enumeration value="default"/> 
      <enumeration value="preserve"/> 
     </restriction> 
    </simpleType> 
</attribute> 
<attributeGroup name="specialAttrs"> 
    <attribute ref="xml:lang"/> 
    <attribute ref="xml:space"/> 
</attributeGroup> 

XJC声称,上述声明的属性已经在别处声明:

parsing a schema... 
[ERROR] 'lang' is already defined 
    line 26 of file:../../gml/3.1.1/smil/xml-mod.xsd 

[ERROR] (related to above error) the first definition appears here 
    line 88 of http://www.w3.org/2001/03/xml.xsd 

[ERROR] 'space' is already defined 
    line 34 of file:../../gml/3.1.1/smil/xml-mod.xsd 

[ERROR] (related to above error) the first definition appears here 
    line 95 of http://www.w3.org/2001/03/xml.xsd 

[ERROR] 'specialAttrs' is already defined 
    line 39 of file:../../gml/3.1.1/smil/xml-mod.xsd 

[ERROR] (related to above error) the first definition appears here 
    line 111 of http://www.w3.org/2001/03/xml.xsd 

Failed to parse a schema. 

做一点研究会导致我相信问题是我需要一个绑定文件来解决重复的属性....我有一个:

<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="../../gml/3.1.1/smil/xml-mod.xsd" node="/xs:schema"> 
    <jaxb:bindings node="//xs:attribute[@name='lang']"> 
     <jaxb:property name="langAttribute"/> 
    </jaxb:bindings> 
    <jaxb:bindings node="//xs:attribute[@name='space']"> 
     <jaxb:property name="spaceAttribute"/> 
    </jaxb:bindings> 
    <jaxb:bindings node="//xs:attributeGroup[@name='specialAttrs']"> 
     <jaxb:property name="specialAttrsAttribute"/> 
    </jaxb:bindings> 
</jaxb:bindings> 

然而问题仍然存在。带或不带绑定文件的错误消息都是相同的。我知道该文件正在使用,因为如果我搞乱了节点选择器的xpath,我会收到一条错误消息。这就像xjc知道绑定文件在那里,但忽略它。

下面是构建失败,绑定的命令行:

C:\tools\jaxb-ri-20110512\bin\xjc -episode ..\..\..\common.ogc -d ..\..\..\src -p com.ogc.bindings -b ..\..\..\bindings.xsd -catalog ..\..\..\ogc.cat -extension sosAll.xsd 

我有两个JDK6本地JAXB(2.0)和JAXB 2.2.4想这(我装的是JAXB-api.jar文件中认可的目录)

回答

0

就像你一样重新尝试编译OGC模式,您可能会发现this project有帮助。它包含编译的SOS模式。

+0

谢谢!那就是诀窍 – user1005939

0

我相信这是一个命名空间冲突的问题,你没有为你的模式元素定义的命名空间,它似乎是你的属性使用名称与XML模式中定义的属性冲突( xml.xsd)

3

如果绑定文件或XSD/WSDL的路径过长,则XJC(与JDK捆绑)会忽略绑定文件。

如果在绑定文件的路径过长时,在Windows 7最终版和Linux上,XJC(与JDK捆绑)上的Oracle 64位JDK 1.6.0.45中观察并确认的问题会忽略绑定文件。

我没有时间做这个问题的详细研究;我通过缩短svn checkout路径解决了我的问题。这是最奇怪的问题 - 我无法在Windows 8笔记本电脑和Linux上重现问题,但在Windows 7工作站上,构建仍然失败。通过确认其他路径,我发现了这个问题,Windows 8的LAPTOP(构建工作)与Windows 7 Ultimate(路径有点长(6个字符 - >/trunk))之间没有区别。

问题解决了,没有任何代码,配置,XML架构或绑定文件的变化。在这里发布,以便其他可能遇到这个问题的人,比我更容易一点。