使用JaxB创建Java类 [英] Create Java classes with JaxB

查看:185
本文介绍了使用JaxB创建Java类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用此XSD中的JaXB创建Java类 http:// pda .rosreestr.ru / upload / www / files / 02_V04_STD_Region_Cadastr_KV.rar 。但是获取此错误。

I try to create Java classes with JaXB from this XSD http://pda.rosreestr.ru/upload/www/files/02_V04_STD_Region_Cadastr_KV.rar . But Get this 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.

当我使用其他模式时,一切都很好。我不擅长使用XML,你能告诉我这些错误意味着什么以及如何解决吗?

When i work with another schemas everything fine. I not good in work with XML, can you tell me what this errors means and how to solve it?

更新

我尝试在类生成中使用binding.xml但是出现此错误。

I try use binding.xml in class generation but get 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

我试试这个绑定:

<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


推荐答案

您可以使用外部绑定文件为其中一种复杂类型指定不同的类名。

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>

xjc命令行将是:

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

这篇关于使用JaxB创建Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆