Генерация классов JAXB для 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
После некоторого поиска в Google я вижу, что мне нужно использовать файл привязки:
<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?
1 ответ
Отказ от ответственности: я являюсь ведущим разработчиком проекта ogc-schemas, который компилирует почти все схемы OGC, включая WFS 1.1.0.
Схемы OGC довольно проблематичны для компиляции. Вам нужно много привязок, настроек и иногда патчей. Поэтому я рекомендую использовать уже скомпилированные schmeas, предоставленные проектом ogc-schemas. Получите этот артефакт для скомпилированных схем WFS 1.1.0.
Для WFS 1.1.0 вам понадобятся несколько привязок:
Кроме того, мне также пришлось применить некоторые незначительные исправления к схемам, такие как исправление относительных URL-адресов местоположения схемы для глобальных и т. Д.:
Но, на самом деле, просто возьмите уже скомпилированные схемы. Это то, о чем этот проект.