xjc绑定自定义在jaxb 2.1.3中不起作用。它适用于jaxb 2.0 [英] xjc binding customization does not work in jaxb 2.1.3. It works in jaxb 2.0

查看:54
本文介绍了xjc绑定自定义在jaxb 2.1.3中不起作用。它适用于jaxb 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JDK 1.6.0中的jaxb 2.0中开发了一个绑定自定义文件,它工作正常。

I developed a binding customization file in jaxb 2.0 in JDK 1.6.0 and it worked fine.

现在我在JDK 1.6中使用jaxb 2.1.3。 0_13它给了我错误:

Now I'm using jaxb 2.1.3 in JDK 1.6.0_13 and it gives me errors:


错误xxx显示在多个属性中

Error xxx shows up in more than one properties

这是绑定文件通过重命名处理的假设。

which is what the binding file is suppose to be handling by renaming them.

2.0和2.1.3之间发生了什么我需要知道,我需要改变什么。我已经近距离搜索,无法弄明白。
非常感谢您的帮助。

What happened between 2.0 and 2.1.3 that I need be aware of and what do I need to change. I've searched near and far and can't figure it out. Thanks so much for your help.

我正在使用绑定自定义文件,因为架构有一些属性名称可以获得全部 属性,因为字段名称由架构的两个不同部分使用。这两个字段称为表达式和断言

I'm using the binding customization file because the schema has a couple property names that would get a "catch-all" property because the field name is used by two different parts of a schema. The 2 fields are called expression and assertion

解析模式时出现以下错误:

I get the following errors parsing a schema:

[ERROR] Element "assertion" shows up in more than one properties.
line 649 of file:/D:/jaxb/extract-xjbfix/090403-0_901-Packet-Schema.xsd

[ERROR] The following location is relevant to the above error
line 647 of file:/D:/jaxb/extract-xjbfix/090403-0_901-Packet-Schema.xsd

[ERROR] Element "expression" shows up in more than one properties.
line 518 of file:/D:/jaxb/extract-xjbfix/090403-0_901-Packet-Schema.xsd

[ERROR] The following location is relevant to the above error
line 516 of file:/D:/jaxb/extract-xjbfix/090403-0_901-Packet-Schema.xsd

[ERROR] Element "expression" shows up in more than one properties.
line 522 of file:/D:/jaxb/extract-xjbfix/090403-0_901-Packet-Schema.xsd

[ERROR] The following location is relevant to the above error
line 516 of file:/D:/jaxb/extract-xjbfix/090403-0_901-Packet-Schema.xsd

Failed to parse a schema.

我的xjc命令是:

xjc -extension 090403-0_901-Packet-Schema.xsd -b binding.xjb

我的xjb文件是:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="2.0"
          xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
          jxb:extensionBindingPrefixes="xjc" >

<jxb:bindings schemaLocation="090403-0_901-Packet-Schema.xsd" node="/xs:schema">

<jxb:globalBindings>
    <xjc:superClass name="com.pw.ietm.XMLExtract.IetmElement"/>
</jxb:globalBindings>

<jxb:schemaBindings>
     <jxb:package name="com.pw.ietm.XMLExtract"/>
</jxb:schemaBindings>

<!-- Modify Expression because expression is used in two different parts of a schema -->

<jxb:bindings node="//xs:complexType[@name='expression_comtype']/xs:choice/xs:sequence[position()=1]/xs:element[@name='expression'][position()=1]">
    <jxb:property name="expressionFirst"/>
</jxb:bindings>

<jxb:bindings node="//xs:complexType[@name='expression_comtype']/xs:choice/xs:sequence[position()=1]/xs:element[@name='expression'][position()=2]">
    <jxb:property name="expressionSecond"/>
</jxb:bindings>

<jxb:bindings node="//xs:complexType[@name='expression_comtype']/xs:choice/xs:sequence[position()=2]/xs:element[@name='expression']">
    <jxb:property name="expressionAlone"/>
</jxb:bindings>

<!-- Modify Loop-step because assertion is used in two different parts of a schema -->

<jxb:bindings node="//xs:complexType[@name='loop-step_comtype']/xs:sequence/xs:element[@name='assertion'][position()=1]">
    <jxb:property name="assertionInitial"/>
</jxb:bindings>

<jxb:bindings node="//xs:complexType[@name='loop-step_comtype']/xs:sequence/xs:element[@name='assertion'][position()=2]">
    <jxb:property name="assertionChanging"/>
</jxb:bindings>

</jxb:bindings> <!-- schemaLocation="090403-0_901-Packet-Schema.xsd" node="/xs:schema" -->

模式非常大但是这里有2个断言和表达式comtype(错误指向的位置):

The schema is very large but here are the 2 assertion and expression comtype (which is where the errors point to):

<xs:complexType name="loop-step_comtype">
<xs:sequence>
<xs:element name="assignment" type="assignment_comtype" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="assertion" type="**assertion_comtype**" minOccurs="0"/>
<xs:element name="expression" type="expression_comtype"/>
<xs:element name="assertion" type="**assertion_comtype**" minOccurs="0"/>
<xs:element name="step-seq" type="step-seq_comtype"/>
</xs:sequence>
<xs:attributeGroup ref="common_attrgroup"/>
</xs:complexType>


<xs:complexType name="expression_comtype">
<xs:choice>
<xs:sequence>
<xs:element name="expression" type="**expression_comtype**"/>
<xs:group ref="binop_elemgroup"/>
<xs:element name="expression" type="**expression_comtype**"/>
</xs:sequence>
<xs:sequence>
<xs:group ref="unop_elemgroup"/>
<xs:element name="expression" type="**expression_comtype**"/>
</xs:sequence>
<xs:element name="property-libref" type="property-libref_comtype"/>
<xs:group ref="value_elemgroup"/>
</xs:choice>
<xs:attributeGroup ref="common_attrgroup"/>
</xs:complexType> 


推荐答案

问题实际上是1.6之后java版本中的一个错误。 0
请参阅 https:// jaxb上的问题642。 dev.java.net/issues/show_bug.cgi?id=642
问题已得到解决,但截止到2009年8月31日没有发布修订版的目标日期。
我将继续使用1.6.0

Problem is actually a bug in java versions after 1.6.0 Please see Issue 642 at https://jaxb.dev.java.net/issues/show_bug.cgi?id=642 Problem has been resolved but as of 8/31/09 no target date for which release the fix will be incorporated. I will continue to use 1.6.0

这篇关于xjc绑定自定义在jaxb 2.1.3中不起作用。它适用于jaxb 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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