2012-10-08 26 views
5

Provo a creare classi Java con JaXB da questo XSD http://pda.rosreestr.ru/upload/www/files/02_V04_STD_Region_Cadastr_KV.rar. Ma ottieni questi errori.Creazione classi Java con JaxB

parsing a schema... 
[WARNING] Simple type "dAllDocuments" was not mapped to Enum due to EnumMemberSizeCap limit. Facets count: 298, current limit: 256. You can use customization attribute "typesafeEnumMaxMembers" to extend the limit. 
line 3 of file:/D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region_Cadastr_KV/dAllDocuments.xsd 

compiling a schema... 
[ERROR] Two declarations cause a collision in the ObjectFactory class. 
line 1645 of file:/D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region_Cadastr_KV/STD_Region_Cadastr_KV.xsd 

[ERROR] (Related to above error) This is the other declaration. 
line 1587 of file:/D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region_Cadastr_KV/STD_Region_Cadastr_KV.xsd 

Failed to produce code. 

quando lavoro con un altro schemi tutto bene. Non sono bravo a lavorare con XML, puoi dirmi cosa significa questo errore e come risolverlo?

UPDATE

provo uso binding.xml nella generazione di classe, ma ottengo questo errore.

C:\Documents and Settings\kliver\Мои документы\Загрузки\jaxb-ri-2.2.6\bin>xjc -d 
out -b binding.xml D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region 
_Cadastr_KV/STD_Region_Cadastr_KV.xsd 
parsing a schema... 
[ERROR] "D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region_Cadastr_KV 
/STD_Region_Cadastr_KV.xsd" is not a part of this compilation. Is this a mistake 
for "file:/D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region_Cadastr 
_KV/STD_Region_Cadastr_KV.xsd"? 
line 6 of file:/C:/Documents%20and%20Settings/kliver/%D0%9C%D0%BE%D0%B8%20%D0% 
B4%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D1%8B/%D0%97%D0%B0%D0%B3%D1%80%D1%8 
3%D0%B7%D0%BA%D0%B8/jaxb-ri-2.2.6/bin/binding.xml 

[WARNING] Simple type "dAllDocuments" was not mapped to Enum due to EnumMemberSi 
zeCap limit. Facets count: 298, current limit: 256. You can use customization at 
tribute "typesafeEnumMaxMembers" to extend the limit. 
line 3 of file:/D:/liferay-develop/workspace/JABX_test/src/02_V04_STD_Region_C 
adastr_KV/dAllDocuments.xsd 

Failed to parse a schema. 

UPDATE2

provo questo legame:

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

    <!-- Raise theEnumMemberSizeCap limit --> 
    <jxb:bindings > 
     <jxb:globalBindings typesafeEnumMaxMembers="2000"/> 
    </jxb:bindings> 

    <jxb:bindings schemaLocation="D:\liferay-develop\workspace\JABX_test\src\02_V04_STD_Region_Cadastr_KV\STD_Region_Cadastr_KV.xsd"> 
     <jxb:bindings node="//xs:complexType[@name='tRight_Owner']"> 
      <jxb:class name="tRight_Owner2"/> 
     </jxb:bindings> 
    </jxb:bindings> 

</jxb:bindings> 

E questo comando da console:

C:\Documents and Settings\kliver\Мои документы\Загрузки\jaxb-ri-2.2.6\bin>xjc -d 
out -b binding.xml D:\liferay-develop\workspace\JABX_test\src\02_V04_STD_Region 
_Cadastr_KV\STD_Region_Cadastr_KV.xsd 
+0

Ebbene, che cosa tipi sono dichiarato alle linee 1587 e 1645 di quel file? Sembra che creino nomi di classi contrastanti, o dovrai unificarli (se rappresentano effettivamente la stessa cosa) o personalizzare i nomi di quei tipi. –

+0

Nella riga 1645 ''. Quindi, come capisco la sua defenzione di tipo 'tRight_Owner'. Ma non vedo altri tipi con questo nome. –

risposta

13

È possibile utilizzare un file delle legature esterni per specificare un nome classe diversa per uno dei tipi complessi.

binding.xml riga di comando

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

    <!-- Raise theEnumMemberSizeCap limit --> 
    <jxb:bindings > 
     <jxb:globalBindings typesafeEnumMaxMembers="2000"/> 
    </jxb:bindings> 

    <jxb:bindings schemaLocation="your-schema.xsd"> 
      <jxb:bindings node="//xs:complexType[@name='tRight_Owner']"> 
       <jxb:class name="TRight_Owner2"/> 
      </jxb:bindings> 
    </jxb:bindings> 

</jxb:bindings> 

Il xjc sarebbe:

xjc -d out -b binding.xml your-schema.xsd 
+0

Ho provato il tuo codice ma ho ricevuto un errore. Per favore guarda UPDATE della domanda. –

+0

@KliverMax - Ho aggiornato la mia risposta per risolvere il limite EnumMemberSizeCap. Potresti pubblicare il file di bind che stai tentando di utilizzare? –

+0

Ho una domanda di aggiornamento, per favore guarda. –

0

Hai un problema con il XSD, ci sono più dichiarazioni con lo stesso nome tRight_Owner
linea 1587:

<xs:complexType> 
         <xs:complexContent> 
          <xs:extension base="tRight_Owner"/> 
         </xs:complexContent> 
        </xs:complexType> 

linea 1645:

<xs:complexType name="tRight_Owner"> 
+1

Ma come risolverlo? –

2

Per quelli di voi imbattersi questa domanda negli anni successivi questo metodo ha funzionato per me.

Ambiente: Netbeans 7.4

metodo Corporatura: Maven - jaxb2-maven-plugin

  1. Creare una cartella denominata xjb in src\main.
  2. In tale cartella creare un file denominato binding.xjb (o qualsiasi altro nome .xjb).

In esso:

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

    <!-- Raise theEnumMemberSizeCap limit --> 
    <jxb:bindings > 
     <jxb:globalBindings typesafeEnumMaxMembers="2000"/> 
    </jxb:bindings> 

</jxb:bindings> 

Nota che questa non è una soluzione alternativa al post di Blaise.

2

Sto usando la versione 0.13.0 del Maven-jaxb2-plugin, e ho trovato il percorso corretto per il file di collegamento è:

src/main/resources/binding.xjb 

Il contenuto è lo stesso di OldCurmudgeon proposto, vale a dire:

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

    <!-- Raise theEnumMemberSizeCap limit --> 
    <jxb:bindings> 
     <jxb:globalBindings typesafeEnumMaxMembers="2000" /> 
    </jxb:bindings> 

</jxb:bindings>