为什么JAXB映射到JAXBElement而不是指定的类型?

THI*_*SOE 5 java xml jaxb

为什么jaxb没有生成指定的类型?它生成了通用List <JAXBElement <?>>,而不是生成指定的类型.

案例是我使用xjc将我的xsd转换为java Obj,

我的xsd,

<xs:complexType name="InputType">
    <xs:choice maxOccurs="unbounded">
        <xs:element name="add" type="AddInputType"/>
        <xs:element name="get" type="GetInputType"/>
        <xs:element name="del" type="DeleteInputType"/>
    </xs:choice>
</xs:complexType> 
Run Code Online (Sandbox Code Playgroud)

生成java类,

public class InputType {

@XmlElementRefs({
    @XmlElementRef(name = "add", type = JAXBElement.class),
    @XmlElementRef(name = "get", type = JAXBElement.class),
    @XmlElementRef(name = "del", type = JAXBElement.class)
})
protected List<JAXBElement<?>> addOrGetOrDel;

public List<JAXBElement<?>> getAddOrGetOrDel() {
    if (addOrGetOrDel == null) {
        addOrGetOrDel = new ArrayList<JAXBElement<?>>();
    }
    return this.addOrGetOrDel;
}
}
Run Code Online (Sandbox Code Playgroud)