有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JAXB外部绑定文件错误

因此,我为waterml2编写了一个外部绑定文件。xsd和迄今为止已经修复了[Error]属性“Rows”已经定义且[Error]属性“Title”已经定义的问题

在解决了这些问题之后,我现在遇到了多个关于碰撞的问题。例如:

[ERROR] A class/interface with the same name "net.opengis.gml._3.SecondDefiningParameter" is already in use. Use a class customization to resolve this conflict.

[Error] Two declarations cause a collision in the ObjectFactory class.


这是绑定文件的外观:

<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>

如果有人对WaterML2.0模式有任何建议,或者之前已经处理过,我将非常感谢您的帮助!谢谢


共 (1) 个答案

  1. # 1 楼答案

    OGC模式需要一些额外的绑定信息来正确运行JAXB。依靠在https://github.com/highsource/ogc-schemas的努力工作,你的境况要好得多

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

    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文件