2011-03-04 167 views
3

我在生成以下類後收到以下錯誤。 我需要以不同的方式運行xjc嗎?JAXB生成的類編譯錯誤

錯誤(261,30):接口foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType已定義爲一個類或接口包圍此範圍

類文件:

// 
// 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> 
* </pre> 
* 
*/ 
public interface EnvelopeType { 


/** 
* 
* @return 
*  possible object is 
*  {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType} 
*/ 
foo.bbs.tbi.firstresponse.EnvelopeType.BodyType getBody(); 

/** 
* 
* @param value 
*  allowed object is 
*  {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType} 
*/ 
void setBody(foo.bbs.tbi.firstresponse.EnvelopeType.BodyType value); 

/** 
* 
* @return 
*  possible object is 
*  {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType} 
*/ 
foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType getHeader(); 

/** 
* 
* @param value 
*  allowed object is 
*  {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType} 
*/ 
void setHeader(foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType value); 


/** 
* 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 29) 
* <p> 
* <pre> 
* &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> 
* </pre> 
* 
*/ 
public interface BodyType { 


    /** 
    * 
    * @return 
    *  possible object is 
    *  {@link java.math.BigInteger} 
    */ 
    java.math.BigInteger getRTVLRQSTID(); 

    /** 
    * 
    * @param value 
    *  allowed object is 
    *  {@link java.math.BigInteger} 
    */ 
    void setRTVLRQSTID(java.math.BigInteger value); 

    /** 
    * 
    * @return 
    *  possible object is 
    *  {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType} 
    */ 
    foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType getFault(); 

    /** 
    * 
    * @param value 
    *  allowed object is 
    *  {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType} 
    */ 
    void setFault(foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType value); 


    /** 
    * 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 33) 
    * <p> 
    * <pre> 
    * &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> 
    * </pre> 
    * 
    */ 
    public interface FaultType { 


     /** 
     * 
     * @return 
     *  possible object is 
     *  {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType} 
     */ 
     foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType getFault(); 

     /** 
     * 
     * @param value 
     *  allowed object is 
     *  {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType} 
     */ 
     void setFault(foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType value); 


     /** 
     * 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 36) 
     * <p> 
     * <pre> 
     * &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> 
     * </pre> 
     * 
     */ 
     public interface FaultType { 


      /** 
      * 
      * @return 
      *  possible object is 
      *  {@link java.math.BigInteger} 
      */ 
      java.math.BigInteger getFaultcode(); 

      /** 
      * 
      * @param value 
      *  allowed object is 
      *  {@link java.math.BigInteger} 
      */ 
      void setFaultcode(java.math.BigInteger value); 

      /** 
      * 
      * @return 
      *  possible object is 
      *  {@link java.lang.String} 
      */ 
      java.lang.String getFaultstring(); 

      /** 
      * 
      * @param value 
      *  allowed object is 
      *  {@link java.lang.String} 
      */ 
      void setFaultstring(java.lang.String value); 

     } 

    } 

} 


/** 
* 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 14) 
* <p> 
* <pre> 
* &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> 
* </pre> 
* 
*/ 
public interface HeaderType { 


    /** 
    * 
    * @return 
    *  possible object is 
    *  {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType} 
    */ 
    foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType getRule(); 

    /** 
    * 
    * @param value 
    *  allowed object is 
    *  {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType} 
    */ 
    void setRule(foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType value); 


    /** 
    * 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 17) 
    * <p> 
    * <pre> 
    * &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> 
    * </pre> 
    * 
    */ 
    public interface RuleType { 


     /** 
     * 
     * @return 
     *  possible object is 
     *  {@link java.math.BigDecimal} 
     */ 
     java.math.BigDecimal getSchemaVersion(); 

     /** 
     * 
     * @param value 
     *  allowed object is 
     *  {@link java.math.BigDecimal} 
     */ 
     void setSchemaVersion(java.math.BigDecimal value); 

     /** 
     * 
     * @return 
     *  possible object is 
     *  {@link java.lang.String} 
     */ 
     java.lang.String getSchemaName(); 

     /** 
     * 
     * @param value 
     *  allowed object is 
     *  {@link java.lang.String} 
     */ 
     void setSchemaName(java.lang.String value); 

     /** 
     * 
     * @return 
     *  possible object is 
     *  {@link java.math.BigInteger} 
     */ 
     java.math.BigInteger getCustomer(); 

     /** 
     * 
     * @param value 
     *  allowed object is 
     *  {@link java.math.BigInteger} 
     */ 
     void setCustomer(java.math.BigInteger value); 

    } 

} 

} 

回答

2

您在這裏遇到的問題是由於Java不讓您使用與外部類相同的簡單名稱聲明內部類而導致的。在類別FaultType中有一個類FaultType,這是禁止的,並且由於在「故障」元素中包含「故障」元素而引起。

我不知道你是否可以告訴JAXB使用不同的命名策略。也許它有助於在XSD中提取命名類型,這應該會導致JAXB生成頂級類而不是嵌套類。

2

剛剛完成Christian的回答。您可以使用綁定(在模式內或外部綁定文件(.xjb))中自定義JAXB將用於特定元素的名稱。 見class binding declarations定製是給定類型生成的類:

如果複雜類型被命名爲:

  • 使用<jxb:bindings node="//xs:complexType[@name=’TypeName’]">指定類型使用XPath語法來定製和:
  • 使用<jxb:class name="CustomizedClassName">來自定義生成的類名稱。

如果複雜類型是命名的,如你的情況,你可以嘗試定製類型的屬性(我沒有嘗試這一點,並不能證明這將工作):

  • 使用<jxb:bindings node=".//xs:element[@name=’elementName’]">指定要自定義的元素(仍爲XPath語法),並且:
  • 使用<jxb:property name="customizedPropertyName"/>可以自定義生成的屬性。