2011-03-04 86 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"/>可以自定义生成的属性。