2012-10-08 14 views
5

このXSD http://pda.rosreestr.ru/upload/www/files/02_V04_STD_Region_Cadastr_KV.rarからJaXBでJavaクラスを作成しようとしています。しかし、このエラーを取得します。JaxBでJavaクラスを作成

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. 

私は別のスキーマですべてうまく動作します。私はXMLを使った作業がうまくいかないので、このエラーの意味と解決方法を教えてください。

UPDATE

私はクラスの生成にbinding.xmlを使用しようとしますが、このエラーを取得します。

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. 

アップデート2

私はこの結合してみてください:

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

そして、このコンソールコマンドを:

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

をさて、どのような種類がありますそのファイルの1587と1645行で宣言されていますか?クラス名が矛盾するように見えますが、それらを統一する必要があります(実際に同じものを表す場合)か、それらの型の名前をカスタマイズする必要があります。 –

+0

行内1645 ''。だから、私は 'tRight_Owner'型の宣言を理解しています。しかし、私はこの名前の別のタイプは見ません。 –

答えて

13

あなたは、複雑なタイプのいずれかに別のクラス名を指定するには、外部バインディングファイルを使用することができます。

binding.xml

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

XJCコマンドラインは次のようになります。この方法は、私のために働いた数年後に、この質問に出くわすあなたのそれらのため

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

私はあなたのコードを試しますが、エラーが発生します。質問の更新を見てください。 –

+0

@ KliverMax - 私はEnumMemberSizeCapの制限に対処するために私の答えを更新しました。あなたが使用しようとしているバインディングファイルを投稿できますか? –

+0

質問を更新してください、それを見てください。 –

0

あなたのXSDに問題がある、複数の宣言があります同じ名前の​​
行1587:

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

が行1645:

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

しかし、それを修正するには? –

2

環境:Netbeansの7.4

ビルド方法:のMaven - JAXB2-mavenの-プラグイン

  1. src\mainxjbというフォルダを作成します。
  2. このフォルダには、binding.xjb(またはその他の.xjbという名前のファイル)を作成します。それに

:これはブレーズのポストに代わる解決策ではないことを

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

注意。

2

私はバージョン0.13を使用しています。maven-JAXB2 - プラグインの0、と私はバインディングファイルへの正しいパスが見つかりました

src/main/resources/binding.xjb 

内容はOldCurmudgeonと同じである、すなわち、提案:

<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> 
関連する問題