9

I tried to create Java classes with JaXB from this XSD http://pda.rosreestr.ru/upload/www/files/02_V04_STD_Region_Cadastr_KV.rar but got these errors.

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.

When I work with another schemas everything is fine. I am not good in work with XML, can you tell me what these errors mean and how to solve it?

UPDATE

I tried to use binding.xml in class generation but got this error.

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

I try this binding:

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

And this console command:

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
2
  • Well, what types are declared at the lines 1587 and 1645 of that file? They seem to create conflicting class names, you'll either need to unify them (if they indeed represent the same thing) or customize the names of those types. Commented Oct 8, 2012 at 9:41
  • In line 1645 <xs:complexType name="tRight_Owner">. So how i understand its defenetion of type tRight_Owner. But i dont see another types with this name. Commented Oct 8, 2012 at 9:48

4 Answers 4

25

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
Sign up to request clarification or add additional context in comments.

4 Comments

I try your code but get error. Please look at UPDATE of question.
@KliverMax - I updated my answer to address the EnumMemberSizeCap limit. Could you post the binding file you are trying to use?
Its works. I fail with path to schema. When i put schema to xjs location its generate classes for me/
If you are using maven-jaxb2-plugin, this example would be helpful: github.com/highsource/maven-jaxb2-plugin/tree/master/tests/res
6

For those of you coming across this question in later years this method worked for me.

Environment: Netbeans 7.4

Build method: Maven - jaxb2-maven-plugin

  1. Create a folder called xjb in src\main.
  2. In that folder create a file called binding.xjb (or any other .xjb name).

In it:

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

Note that this is not an alternative solution to Blaise's post.

Comments

4

I'm using version 0.13.0 of the maven-jaxb2-plugin, and I found the correct path to the binding file is:

src/main/resources/binding.xjb

The content is the same as OldCurmudgeon proposed, namely:

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

Comments

0

You have an issue with your XSD, there are multiple declarations of same name tRight_Owner
line 1587:

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

line 1645:

<xs:complexType name="tRight_Owner">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.