繁体   English   中英

为 http://schemas.opengis.net/wfs/1.1.0/wfs.xsd 生成 JAXB 类

[英]Generating JAXB classes for http://schemas.opengis.net/wfs/1.1.0/wfs.xsd

我正在尝试使用 JAXB 为这个模式生成类: http : //schemas.opengis.net/wfs/1.1.0/wfs.xsd

我将该架构下载到本地文件,现在我正在尝试生成 JAXB 类。 首先我得到这个错误:

[ERROR] Property "Title" is already defined. Use <jaxb:property> to resolve this conflict.
  line 261 of http://www.w3.org/1999/xlink.xsd

经过一番谷歌搜索,我发现我需要使用绑定文件:

<jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jxb:bindings schemaLocation="http://www.w3.org/1999/xlink.xsd"
        node="/xs:schema">

        <jxb:bindings node="//xs:attributeGroup[@name='locatorAttrs']">
            <jxb:bindings node=".//xs:attribute[@ref='xlink:title']">
                <jxb:property name="title1" />
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xs:attributeGroup[@name='arcAttrs']">
            <jxb:bindings node=".//xs:attribute[@ref='xlink:title']">
                <jxb:property name="title2" />
            </jxb:bindings>
        </jxb:bindings>

    </jxb:bindings>

    <jxb:bindings
        schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd"
        node="/xs:schema">
        <jxb:bindings node="//xs:element[@name='_Solid']">
            <jxb:factoryMethod name="gmlAbstractSolidElementFactory" />
        </jxb:bindings>
    </jxb:bindings>

</jxb:bindings>

但是当我使用该绑定文件时,我收到了大量其他错误:

parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "ncr.request.FeatureCollectionType" is already in use. Use a class customization to resolve this conflict.
  line 846 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] (Relevant to above error) another "FeatureCollectionType" is generated from here.
  line 117 of http://schemas.opengis.net/gml/3.1.1/base/feature.xsd

[ERROR] A class/interface with the same name "ncr.request.ArcType" is already in use. Use a class customization to resolve this conflict.
  line 217 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] (Relevant to above error) another "ArcType" is generated from here.
  line 265 of http://www.w3.org/1999/xlink.xsd

[ERROR] A class/interface with the same name "ncr.request.CodeType" is already in use. Use a class customization to resolve this conflict.
  line 162 of http://schemas.opengis.net/gml/3.1.1/base/basicTypes.xsd

[ERROR] (Relevant to above error) another "CodeType" is generated from here.
  line 49 of http://schemas.opengis.net/ows/1.0.0/ows19115subset.xsd

[ERROR] A class/interface with the same name "ncr.request.GetCapabilitiesType" is already in use. Use a class customization to resolve this conflict.
  line 168 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] (Relevant to above error) another "GetCapabilitiesType" is generated from here.
  line 40 of http://schemas.opengis.net/ows/1.0.0/owsGetCapabilities.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 846 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 117 of http://schemas.opengis.net/gml/3.1.1/base/feature.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 217 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 265 of http://www.w3.org/1999/xlink.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 162 of http://schemas.opengis.net/gml/3.1.1/base/basicTypes.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 49 of http://schemas.opengis.net/ows/1.0.0/ows19115subset.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 168 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 40 of http://schemas.opengis.net/ows/1.0.0/owsGetCapabilities.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 1088 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 90 of http://schemas.opengis.net/gml/3.1.1/base/geometryBasic2d.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 838 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 99 of http://schemas.opengis.net/gml/3.1.1/base/feature.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 167 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 38 of http://schemas.opengis.net/ows/1.0.0/owsGetCapabilities.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 99 of http://schemas.opengis.net/gml/3.1.1/base/feature.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 115 of http://schemas.opengis.net/gml/3.1.1/base/feature.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 298 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 317 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 24 of http://schemas.opengis.net/ows/1.0.0/ows19115subset.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 167 of http://www.w3.org/1999/xlink.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 257 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 276 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 102 of http://schemas.opengis.net/gml/3.1.1/smil/smil20-language.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 136 of http://schemas.opengis.net/gml/3.1.1/smil/smil20.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 206 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 225 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 124 of http://schemas.opengis.net/gml/3.1.1/smil/smil20.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 70 of http://schemas.opengis.net/gml/3.1.1/smil/smil20-language.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 18 of http://schemas.opengis.net/gml/3.1.1/base/geometryBasic2d.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 925 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 65 of http://schemas.opengis.net/gml/3.1.1/smil/smil20.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 34 of http://schemas.opengis.net/gml/3.1.1/smil/smil20-language.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 215 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 241 of http://www.w3.org/1999/xlink.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 17 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 287 of http://schemas.opengis.net/gml/3.1.1/base/geometryBasic0d1d.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 24 of http://schemas.opengis.net/filter/1.1.0/expr.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 89 of file:/C:/Users/kworkman/workspace/NcrApi/schemas/request2/wfs.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 86 of http://schemas.opengis.net/gml/3.1.1/smil/smil20-language.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 130 of http://schemas.opengis.net/gml/3.1.1/smil/smil20.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 68 of http://schemas.opengis.net/ows/1.0.0/owsCommon.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 188 of http://schemas.opengis.net/gml/3.1.1/base/referenceSystems.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 78 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 97 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 174 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 155 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 41 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

[ERROR] (Related to above error) This is the other declaration.
  line 56 of http://schemas.opengis.net/gml/3.1.1/base/defaultStyle.xsd

Failed to produce code.

我有点惊讶,因为这看起来像是其他人会为其生成 JAXB 类的模式,但 google 似乎没有发现任何东西。 我以前使用过 JAXB,但这似乎比我过去看到的更复杂。

是否有我需要为此模式使用的特定绑定文件,或者某些特定的 JAXB 设置?

免责声明:我是ogc-schemas项目的首席开发人员,该项目编译了几乎所有 OGC 模式,包括WFS 1.1.0

OGC 模式的编译问题很大。 您需要大量绑定、自定义,有时还需要补丁。 所以我的建议是使用ogc-schemas项目提供的已经编译好的 schmeas。 为已编译的 WFS 1.1.0 模式获取此工件

对于 WFS 1.1.0,您需要一些绑定:

除此之外,我还必须对模式应用一些小补丁,例如将相对模式位置 URL 更正为全局等:

但是,实际上,只需采用已编译的模式即可。 这就是这个项目的意义所在。

@lexicore我在尝试为WFS 2.0生成JAXB类时遇到相同的问题。 我需要在客户端中使用它们来与WFS 2.0.0一起使用。不幸的是,在mavenrepository中,没有用于WFS 2.0架构的JAR(org.geotools.schemas»wfs-2。)只有wfs.xsd文件。 我想念什么吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM