首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于OGC模式的Jaxb

用于OGC模式的Jaxb
EN

Stack Overflow用户
提问于 2013-01-11 22:11:28
回答 1查看 3.5K关注 0票数 2

这是我的方案(scheme1.xsd)

代码语言:javascript
复制
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:app="http://www.deegree.org/app" xmlns:deegreewfs="http://www.deegree.org/wfs" xmlns:dgjdbc="http://www.deegree.org/jdbc" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.deegree.org/app">
    <xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd" />
    <xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/geometryAggregates.xsd" />
    <xs:import namespace="http://www.opengis.net/wfs" schemaLocation="http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" />
    <!-- CONFIGURACI N DE LA BASE DE DATOS -->
    <!-- ==============================Genera una clave como identificador======================================== -->
    <xs:element name="Entidad" substitutionGroup="gml:_Feature" type="app:EntidadType">
        <!-- DEFINICI N DE GML:ID -->
    </xs:element>
    <!-- ==============================RESOLUCION DE CAMPOS======================================== -->
    <xs:complexType name="EntidadType">
        <xs:complexContent>
            <xs:extension base="gml:AbstractFeatureType">
                <xs:sequence>
                    <!-- Campo simple - INTEGER -->
                    <xs:element name="fid" type="xs:integer">
                    </xs:element>
                    <!-- Campo simple - INTEGER -->
                    <xs:element name="nombreEntidad_nombre" type="xs:string">
                    </xs:element>
                    <xs:element name="entidadLocal_municipioReal" type="xs:string">
                    </xs:element>
                    <xs:element name="entidadLocal_municipio" type="xs:string">
                    </xs:element>
                    <xs:element name="entidadLocal_provinciaReal" type="xs:string">
                    </xs:element>
                    <xs:element name="entidadLocal_provincia" type="xs:string">
                    </xs:element>
                    <xs:element name="posicionEspacial_BBOX" type="gml:GeometryPropertyType">
                    </xs:element>
                    <xs:element name="posicionEspacial_Centroide" type="xs:string">
                    </xs:element>
                    <!-- GEOM -->
                    <xs:element name="geom" type="gml:GeometryPropertyType">
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

当我使用:

代码语言:javascript
复制
xjc scheme1.xsd

我明白了:

代码语言:javascript
复制
parsing a schema...
[ERROR] Property "Title" is already defined. Use &lt;jaxb:property> to resolve this conflict.
line 232 of "http://www.w3.org/1999/xlink.xsd"

[ERROR] The following location is relevant to the above error
line 219 of "http://www.w3.org/1999/xlink.xsd"

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

[ERROR] The following location is relevant to the above error
line 246 of "http://www.w3.org/1999/xlink.xsd"

Failed to parse a schema.

我使用了这个文件(binding.xjb):

代码语言:javascript
复制
<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>

xjc scheme1.xsd -b binding.xjb

我得到了这个错误:

代码语言:javascript
复制
parsing a schema...
compiling a schema...
[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 1466 of http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.xsd

[ERROR] (Related to above error) This is the other declaration.   
line 1520 of "http://schemas.opengis.net/gml/3.1.1/base/geometryPrimitives.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 287 of "http://schemas.opengis.net/gml/3.1.1/base/geometryBasic0d1d.xsd"

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2013-01-26 01:42:55

问题是,xjc构建的ObjectFactory将包含一个工厂方法,用于包中的元素,在您的示例中:

在geometryPrimitives.xsd上,1466行:

代码语言:javascript
复制
<element name="_Solid" type="gml:AbstractSolidType" abstract="true" ...

在第1520行:

代码语言:javascript
复制
<element name="Solid" type="gml:SolidType" substitutionGroup="gml:_Solid"/>

它们都会在ObjectFactory中创建一个叫做"createSolid()“的工厂方法。要解决此问题,您可以在binding.xjb中包含类似以下内容:

代码语言:javascript
复制
<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>

如果冲突来自不同的模式文件,您可以指定希望每个模式位于哪个包中。这样,您不必替换每个冲突的工厂方法名称,从而节省时间:

代码语言:javascript
复制
<bindings schemaLocation="../path/to/my.xsd">
   <schemaBindings>
      <package name="org.acme.foo"/>
   </schemaBindings>
</bindings>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14279887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档