javaxsd代码生成问题

javaxsd代码生成问题,java,xsd,xjc,Java,Xsd,Xjc,我现在有一个XSD看起来像这样 <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="apiCategoryResponse"> <xs:complexType> <xs:sequence

我现在有一个XSD看起来像这样

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="apiCategoryResponse">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="category"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="category">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="version"/>
        <xs:element ref="name"/>
        <xs:element ref="desc"/>
        <xs:element ref="id"/>
        <xs:element maxOccurs="unbounded" ref="subCategory"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="subCategory">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="childCategory"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="version" type="xs:integer"/>
  <xs:element name="name" type="xs:NCName"/>
  <xs:element name="desc" type="xs:NCName"/>
  <xs:element name="id" type="xs:integer"/>
  <xs:element name="childCategory">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="childCategory"/>
        <xs:element ref="desc"/>
        <xs:element ref="id"/>
        <xs:element ref="name"/>
        <xs:element ref="version"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "childCategoryOrDescOrId"
})
@XmlRootElement(name = "childCategory")
public class ChildCategory {

    @XmlElementRefs({
        @XmlElementRef(name = "name", type = JAXBElement.class),
        @XmlElementRef(name = "id", type = JAXBElement.class),
        @XmlElementRef(name = "version", type = JAXBElement.class),
        @XmlElementRef(name = "childCategory", type = ChildCategory.class),
        @XmlElementRef(name = "desc", type = JAXBElement.class)
    })
    protected List<Object> childCategoryOrDescOrId;

    /**
     * Gets the value of the childCategoryOrDescOrId property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the childCategoryOrDescOrId property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getChildCategoryOrDescOrId().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
     * {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
     * {@link JAXBElement }{@code <}{@link String }{@code >}
     * {@link ChildCategory }
     * {@link JAXBElement }{@code <}{@link String }{@code >}
     * 
     * 
     */
    public List<Object> getChildCategoryOrDescOrId() {
        if (childCategoryOrDescOrId == null) {
            childCategoryOrDescOrId = new ArrayList<Object>();
        }
        return this.childCategoryOrDescOrId;
    }

}
* * * *列表中允许以下类型的对象 *{@link JAXBElement}{@code} *{@link JAXBElement}{@code} *{@link JAXBElement}{@code} *{@link ChildCategory} *{@link JAXBElement}{@code} * * */ 公共列表getChildCategoryOrDescOrId(){ 如果(ChildCategoryDescrorId==null){ childCategoryOrDescOrId=newarraylist(); } 返回此.childCategoryOrDescOrId; } } 问题是我不希望它是desc/id/name/等的列表


我希望这些字段有单独的setter和getter,而childCategory是一个可以包含另一个childCategory列表以及它自己的desc/name/version等值的列表。基本上,我希望从XJC自动生成显式setter和getter。所有其他方法都失败了我总是可以手动编写代码,但我想知道是否有一些技巧可以迫使XJC按照我希望的方式生成代码。

为什么不做与您为
类别所做的相同的事情呢


<xs:element name="childCategory">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="desc" />
      <xs:element ref="id" />
      <xs:element ref="name" />
      <xs:element ref="version" />
      <xs:element ref="childCategory" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
</xs:element>