【问题标题】:JAXB External Binding File ErrorJAXB 外部绑定文件错误
【发布时间】:2016-06-21 17:54:59
【问题描述】:

所以我已经为 waterml2.xsd 编写了一个外部绑定文件,并且到目前为止已经修复了 [Error] 属性“Rows”已定义并且 [Error] 属性“Title”已定义。

修复这些问题后,我现在遇到了多个处理碰撞的问题。例如:

[错误] 同名的类/接口 “net.opengis.gml._3.SecondDefiningParameter”已在使用中。用一个 类自定义来解决这个冲突。

[错误] 两个声明导致 ObjectFactory 类发生冲突。


这是绑定文件的样子:

<bindings xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<!-- In geometryPrimitives.xsd, fix so element and attribute both with name "rows" don't conflict -->
<bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/geometryPrimitives.xsd" version="3.2.1.2">
<bindings node="//xs:group/xs:sequence/xs:element[@name='rows']">
<property name="rowsElement"/>
</bindings>
</bindings>
<!-- In xlink.xsd, fix so element and attributes don't have the same "titles" conflict -->
<bindings schemaLocation="http://www.w3.org/1999/xlink.xsd" node="/xs:schema">
<schemaBindings>
<package name="net.opengis.wfs._2_1"/>
</schemaBindings>
</bindings>
<bindings schemaLocation="http://www.w3.org/1999/xlink.xsd" node="/xs:schema">
<bindings node="//xs:attributeGroup[@name='locatorAttrs']">
<bindings node=".//xs:attribute[@ref='xlink:title']">
<property name="LocatorAttrsTitle"/>
</bindings>
</bindings>
<bindings node="//xs:group[@name='locatorModel']">
<bindings node=".//xs:element[@ref='xlink:title']">
<property name="LocatorModelTitle"/>
</bindings>
</bindings>
<bindings node="//xs:attributeGroup[@name='arcAttrs']">
<bindings node=".//xs:attribute[@ref='xlink:title']">
<property name="ArcAttrsTitle"/>
</bindings>
</bindings>
<bindings node="//xs:group[@name='arcModel']">
<bindings node=".//xs:element[@ref='xlink:title']">
<property name="ArcModelTitle"/>
</bindings>
</bindings>
</bindings>
</bindings>

如果有人有任何建议或处理过 WaterML 2.0 架构,我将不胜感激!谢谢。

【问题讨论】:

    标签: java binding jaxb external


    【解决方案1】:

    OGC 模式需要一些额外的绑定信息才能通过 JAXB 正确运行。依靠https://github.com/highsource/ogc-schemas 的辛勤工作,你会好很多。

    要使用 highsource 绑定,最好只克隆存储库并使用 maven 构建绑定(这个项目中有很好的 maven 构建支持)。 IE。

    git clone https://github.com/highsource/ogc-schemas.git
    mvn install –D skipTests
    

    我跳过了测试以加快速度,但我遇到了一个测试失败的问题。

    您也可以将基础 pom.xml 导入 Eclipse(或您使用的任何 IDE)并让 maven 构建通过。

    一旦构建完成,您应该会在相关文件夹下获得绑定。例如。 WaterML2.0:

    ls waterml/2.0/target/generated-sources/xjc/net/opengis/waterml/v_2_0/
    
    CategoricalTVPType.java
    CategoricalTimeseriesType.java
    CollectionPropertyType.java
    CollectionType.java
    CommentBlockPropertyType.java
    and so on..
    

    在 target/classes 文件夹中有一个 XJB 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      相关资源
      最近更新 更多