2013-01-11 2 views
2

Ce Schemas est mon schéma (scheme1.xsd)JAXB pour OGC

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

Quand j'utilise:

xjc scheme1.xsd 

Je reçois ceci:

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. 

J'ai utilisé ce fichier (liaison.xjb):

<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 

Je reçois cette erreur:

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" 

Qu'est-ce que je fais mal?

Répondre

2

Le problème est que le ObjectFactory qui xjc construit contiendra une méthode d'usine pour les éléments à l'intérieur du paquet et dans votre cas:

Sur geometryPrimitives.xsd, ligne 1466:

<element name="_Solid" type="gml:AbstractSolidType" abstract="true" ... 

Et ligne 1520:

<element name="Solid" type="gml:SolidType" substitutionGroup="gml:_Solid"/> 

les deux crée une méthode de fabrication appelé quelque chose comme « CréerSolide() » à l'intérieur ObjectFactory. Pour corriger cela, vous pouvez inclure dans vous binding.xjb quelque chose comme ce qui suit:

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

Si les collisions sont de différents fichiers de schéma, vous pouvez spécifier dans quel paquet vous voulez que chaque schéma. De cette façon, vous gagnez du temps en n'ayant pas à substituer le nom de chaque nom de méthode d'usine entré en collision:

<bindings schemaLocation="../path/to/my.xsd"> 
    <schemaBindings> 
     <package name="org.acme.foo"/> 
    </schemaBindings> 
</bindings>