Generating JAXB classes for http://schemas.opengis.net/wfs/1.1.0/wfs.xsd
Asked Answered
L

1

7

I'm trying to use JAXB to generate classes for this schema: http://schemas.opengis.net/wfs/1.1.0/wfs.xsd

I downloaded that schema to a local file, and now I'm trying to generate the JAXB classes. First I get this error:

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

After some googling, I see that I need to use a binding file:

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

But then when I use that binding file, I get a ton of other errors:

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.

I'm a little surprised, just because this seems like a schema that other people would have generated JAXB classes for, but google doesn't seem to turn anything up. I've used JAXB before, but this seems to be more involved than what I've seen in the past.

Is there a specific binding file that I need to use for this schema, or maybe some specific JAXB settings?

Lashley answered 16/11, 2015 at 15:24 Comment(1)
@laune These are preexisting schemas, so I can't change them. And I guess I'm asking what those bindings or patches would be.Lashley
I
8

Disclaimer: I'm the lead dev of the ogc-schemas project which compiles almost all OGC schemas including WFS 1.1.0.

OGC Schemas are quite problematic to compile. You need a lot of bindings, customizations and sometimes patches. So my recommendation would be just to use the already compiled schmeas provided by the ogc-schemas project. Get this artifact for the compiled WFS 1.1.0 schemas.

For WFS 1.1.0 you'll need a few bindings:

Apart from that I also had to apply some minor patches to the schemas like correcting relative schema location URLs to global etc:

But, really, just take the already compiled schemas. This is what this project is about.

Irremeable answered 16/11, 2015 at 18:43 Comment(7)
Good to know. I had at least one other complaint about these xsds over the years. - There should be a comment in the xsd files ("Don't xjc, use...") if they can't be patched without hurting the XML structure.Potoroo
@Potoroo Patches are mostly trivial (URL correction) but there are a few things just to make XJC happy. As far as I understand, XML stucture is mostly the same or at least closely compatible.Irremeable
@Irremeable This looks very promising. I can't use maven right now (gotta love corporate firewalls), so I'm trying to use your binding files to generate the JAXB classes myself. I get this error: Unsupported binding namespace "http://jaxb2-commons.dev.java.net/basic/wildcard". Perhaps you meant "http://jaxb.dev.java.net/plugin/code-injector"? line 2 of http://schemas.opengis.net/gml/3.1.1/base/feature.xsdLashley
@KevinWorkman You don't have to use Maven. Just download the JARs. Here's on the wildcard plugin. You'll also need jaxb2-annotate-plugin. But really, just take the JARs.Irremeable
@Irremeable I'm probably just being stupid, but I don't see a place to just get the jars?Lashley
@KevinWorkman See the last link in my last comment: repo1.maven.org/maven2/org/jvnet/ogc/wfs-v_1_1_0/2.5.2 for WFS 1.1.0. You'll also need XLink 1.0, GML 3.1.1, Filter 1.1.0 and OWS 1.0.0. You can use search.maven.org to search for artifacts.Irremeable
@Irremeable After some tinkering, I finally got it working. Thanks so much! Seems a bit crazy that OpenGIS would use such a convoluted schema...Lashley

© 2022 - 2024 — McMap. All rights reserved.