Настройка связывания xjc не работает в jaxb 2.1.3. Работает в jaxb 2.0 - PullRequest
2 голосов
/ 15 мая 2009

Я разработал файл настройки привязки в jaxb 2.0 в JDK 1.6.0, и он работал нормально.

Теперь я использую jaxb 2.1.3 в JDK 1.6.0_13, и это дает мне ошибки:

Ошибка xxx обнаруживается в нескольких свойствах

Это то, что файл привязки должен обрабатывать, переименовывая их.

Что произошло между 2.0 и 2.1.3, о чем мне нужно знать, и что мне нужно изменить. Я искал близко и далеко и не могу понять это. Большое спасибо за вашу помощь.

Я использую файл настройки привязки, потому что схема имеет пару имен свойств, которые получат свойство "catch-all", потому что имя поля используется двумя разными частями схемы. 2 поля называются выражением и утверждением

Я получаю следующие ошибки при разборе схемы:

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

Схема очень большая, но вот два типа утверждения и выражения (на которые указывают ошибки):

<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 Ответ

0 голосов
/ 31 августа 2009

Проблема на самом деле ошибка в Java-версиях после 1.6.0 Пожалуйста, смотрите выпуск 642 на https://jaxb.dev.java.net/issues/show_bug.cgi?id=642 Проблема была решена, но по состоянию на 31.08.09 не было запланированной даты выпуска исправления. Я буду продолжать использовать 1.6.0

...