Ошибка компиляции в сгенерированном классе JAXB - PullRequest
3 голосов
/ 04 марта 2011

Я получаю следующую ошибку после того, как сгенерировал следующий класс. Нужно ли запускать xjc по-другому?

Ошибка (261,30): интерфейс foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType уже определен как класс или интерфейс, охватывающий эту область действия

файл класса:

<code>//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference   Implementation, v1.0.2-b15-fcs 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2011.03.03 at 04:15:50 PST 
//


package foo.bbs.tbi.firstresponse;


/**
 * Java content class for anonymous complex type.
 * <p>The following schema fragment specifies the expected content contained within   this java content object. (defined at file:/D:/tools/trang/trang-  20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 11)
 * <p>
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="Header">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="rule">
 *                     &lt;complexType>
 *                       &lt;complexContent>
 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema} anyType">
 *                           &lt;sequence>
 *                             &lt;element name="customer"  type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                             &lt;element name="schemaName" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
 *                             &lt;element name="schemaVersion" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
 *                           &lt;/sequence>
 *                         &lt;/restriction>
 *                       &lt;/complexContent>
 *                     &lt;/complexType>
 *                   &lt;/element>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *         &lt;element name="Body">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;choice>
 *                   &lt;element name="RTVL_RQST_ID"  type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                   &lt;element name="Fault">
 *                     &lt;complexType>
 *                       &lt;complexContent>
 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                           &lt;sequence>
 *                             &lt;element name="fault">
 *                               &lt;complexType>
 *                                 &lt;complexContent>
 *                                   &lt;restriction  base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                                     &lt;sequence>
 *                                       &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                                       &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *                                     &lt;/sequence>
 *                                   &lt;/restriction>
 *                                 &lt;/complexContent>
 *                               &lt;/complexType>
 *                             &lt;/element>
 *                           &lt;/sequence>
 *                         &lt;/restriction>
 *                       &lt;/complexContent>
 *                     &lt;/complexType>
 *                   &lt;/element>
 *                 &lt;/choice>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * 
* * / открытый интерфейс EnvelopeType { / ** * * @вернуть * возможный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType} * / foo.bbs.tbi.firstresponse.EnvelopeType.BodyType getBody (); / ** * * @param value * разрешенный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType} * / void setBody (значение foo.bbs.tbi.firstresponse.EnvelopeType.BodyType); / ** * * @вернуть * возможный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType} * / foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType getHeader (); / ** * * @param value * разрешенный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType} * / void setHeader (значение foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType); / ** * Класс содержимого Java для анонимного сложного типа. *

Следующий фрагмент схемы определяет ожидаемое содержимое, содержащееся в этом объекте содержимого Java. (определено в файле: / D: / tools / trang / trang- 20091111 / tbi / firstResponseOnly / jaxb2 / firstCombined.xsd строка 29) *

*

 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;choice>
 *         &lt;element name="RTVL_RQST_ID" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *         &lt;element name="Fault">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="fault">
 *                     &lt;complexType>
 *                       &lt;complexContent>
 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                           &lt;sequence>
 *                             &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                             &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *                           &lt;/sequence>
 *                         &lt;/restriction>
 *                       &lt;/complexContent>
 *                     &lt;/complexType>
 *                   &lt;/element>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/choice>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * 
* * / открытый интерфейс BodyType { / ** * * @вернуть * возможный объект * {@link java.math.BigInteger} * / java.math.BigInteger getRTVLRQSTID (); / ** * * @param value * разрешенный объект * {@link java.math.BigInteger} * / void setRTVLRQSTID (значение java.math.BigInteger); / ** * * @вернуть * возможный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType} * / foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType getFault (); / ** * * @param value * разрешенный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType} * / void setFault (значение foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType); / ** * Класс содержимого Java для анонимного сложного типа. *

Следующий фрагмент схемы определяет ожидаемое содержимое, содержащееся в этом объекте содержимого Java. (определено в файле: / D: /tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd строка 33) *

*

     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="fault">
     *           &lt;complexType>
     *             &lt;complexContent>
     *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *                 &lt;sequence>
     *                   &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
     *                   &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
     *                 &lt;/sequence>
     *               &lt;/restriction>
     *             &lt;/complexContent>
     *           &lt;/complexType>
     *         &lt;/element>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * 
* * / открытый интерфейс FaultType { / ** * * @вернуть * возможный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType} * / foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType getFault (); / ** * * @param value * разрешенный объект * {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType} * / void setFault (значение foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType); / ** * Класс содержимого Java для анонимного сложного типа. *

Следующий фрагмент схемы определяет ожидаемое содержимое, содержащееся в этом объекте содержимого Java. (определено в файле: / D: /tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd строка 36) *

*

         * &lt;complexType>
         *   &lt;complexContent>
         *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
         *       &lt;sequence>
         *         &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
         *         &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
         *       &lt;/sequence>
         *     &lt;/restriction>
         *   &lt;/complexContent>
         * &lt;/complexType>
         * 
* * / открытый интерфейс FaultType { / ** * * @вернуть * возможный объект * {@link java.math.BigInteger} * / java.math.BigInteger getFaultcode (); / ** * * @param value * разрешенный объект * {@link java.math.BigInteger} * / void setFaultcode (значение java.math.BigInteger); / *** * @return * возможный объект: * {@link java.lang.String} * / java.lang.String getFaultstring ();/ ** * * @param value * допустимым объектом является * {@link java.lang.String} * / void setFaultstring (java.lang.String value);}}} / ** * Класс содержимого Java для анонимного сложного типа.*

Следующий фрагмент схемы определяет ожидаемое содержимое, содержащееся в этом объекте содержимого Java.(определено в файле: / D: /tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd строка 14) *

*

 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="rule">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="customer" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                   &lt;element name="schemaName" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
 *                   &lt;element name="schemaVersion" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * 
* * / открытый интерфейс HeaderType {/ ** * * @return * возможный объект: * {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType} * / foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType getRule ();/ ** * * @param value * допустимым объектом является * {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType} * / void setRule (foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType value);/ ** * Класс содержимого Java для анонимного сложного типа.*

Следующий фрагмент схемы определяет ожидаемое содержимое, содержащееся в этом объекте содержимого Java.(определено в файле: / D: /tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd строка 17) *

*

     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="customer" type="{http://www.w3.org/2001/XMLSchema}integer"/>
     *         &lt;element name="schemaName" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
     *         &lt;element name="schemaVersion" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * 
* * / открытый интерфейс RuleType {/ ** * * @return * возможный объект: * {@link java.math.BigDecimal} * / java.math.BigDecimal getSchemaVersion ();/ ** * * @param value * допустимым объектом является * {@link java.math.BigDecimal} * / void setSchemaVersion (java.math.BigDecimal value);/ ** * * @return * возможным объектом является * {@link java.lang.String} * / java.lang.String getSchemaName ();/ ** * * @param value * допустимым объектом является * {@link java.lang.String} * / void setSchemaName (java.lang.String value);/ ** * * @return * возможным объектом является * {@link java.math.BigInteger} * / java.math.BigInteger getCustomer ();/ ** * * @param value * допустимым объектом является * {@link java.math.BigInteger} * / void setCustomer (java.math.BigInteger value);}}}

Ответы [ 2 ]

2 голосов
/ 08 июля 2011

Просто завершаю ответ Кристиана. Вы можете настроить имя, которое JAXB будет использовать для определенного элемента, используя bindings (либо внутри схемы, либо во внешнем файле привязок (.xjb)). См. объявления привязки класса , чтобы настроить класс, сгенерированный для данного типа:

Если комплексный тип назван:

  • Используйте <jxb:bindings node="//xs:complexType[@name=’TypeName’]">, чтобы указать тип для настройки с использованием синтаксиса XPath, и:
  • Используйте <jxb:class name="CustomizedClassName"> для настройки сгенерированного имени класса.

Если сложный тип имеет имя , а не , как в вашем случае, вы можете попробовать настроить свойство типа (я не пробовал и не могу подтвердить, что это будет работать):

  • Используйте <jxb:bindings node=".//xs:element[@name=’elementName’]">, чтобы указать элемент для настройки (все еще синтаксис XPath), и:
  • Используйте <jxb:property name="customizedPropertyName"/> для настройки сгенерированного свойства.
2 голосов
/ 05 марта 2011

Проблема, с которой вы здесь сталкиваетесь, вызвана тем, что Java не позволяет вам объявить внутренний класс с тем же простым именем, что и внешний класс.У вас есть класс FaultType внутри класса FaultType, который запрещен и вызван наличием элемента "fault" внутри элемента "Fault".

Я не знаю, можете ли вы сказать JAXBиспользовать другую стратегию именования.Возможно, это помогает извлечь именованные типы в XSD, что должно заставить JAXB генерировать классы верхнего уровня вместо вложенных классов.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...