xjc 绑定自定义在 jaxb 2.1.3 中不起作用。 它适用于 jaxb 2.0
我在 JDK 1.6.0 中的 jaxb 2.0 中开发了一个绑定自定义文件,并且运行良好。
现在我在 JDK 1.6.0_13 中使用 jaxb 2.1.3,它给了我错误:
错误 xxx 出现在多个属性中
,这是绑定文件应该通过重命名它们来处理的属性。
2.0 和 2.1.3 之间发生了哪些我需要了解的事情以及我需要更改哪些内容。 我近近寻遍了,也查不出来。 非常感谢你的帮助。
我正在使用绑定自定义文件,因为该架构有几个属性名称,这些属性名称将获得“包罗万象”的属性,因为字段名称由架构的两个不同部分使用。 这两个字段称为表达式和断言
我在解析架构时遇到以下错误:
[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(这是错误指向的地方):
<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>
I developed a binding customization file in jaxb 2.0 in JDK 1.6.0 and it worked fine.
Now I'm using jaxb 2.1.3 in JDK 1.6.0_13 and it gives me errors:
Error xxx shows up in more than one properties
which is what the binding file is suppose to be handling by renaming them.
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.
my xjc command is :
xjc -extension 090403-0_901-Packet-Schema.xsd -b binding.xjb
my xjb file is:
<?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" -->
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题实际上是1.6.0之后java版本的一个bug
请参阅问题 642:https://jaxb.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