9

この XSD http://pda.rosreestr.ru/upload/www/files/02_V04_STD_Region_Cadastr_KV.rarから 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 を扱うのが苦手なのですが、これらのエラーの意味と解決方法を教えてもらえますか?

アップデート

クラス生成で 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
4

4 に答える 4

22

You can use an external bindings file to specify a different class name for one of the complex types.

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>

The xjc command line would be:

xjc -d out -b binding.xml your-schema.xsd
于 2012-10-08T10:14:04.467 に答える
4

後年この質問に出くわした人にとって、この方法は私にとってはうまくいきました。

環境: Netbeans 7.4

ビルド方法: Maven - jaxb2-maven-plugin

  1. というフォルダを作成しxjbますsrc\main
  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>

これは Blaise の投稿に代わる解決策ではないことに注意してください。

于 2014-01-23T12:00:14.793 に答える
4

私は maven-jaxb2-plugin のバージョン 0.13.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>
于 2015-09-15T08:54:53.887 に答える
0

XSD に問題があります。同じ名前のtRight_Owner
行 1587の複数の宣言があります。

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

1645行目:

<xs:complexType name="tRight_Owner">
于 2012-10-08T09:49:04.680 に答える