简体   繁体   中英

Jaxb API - Remove JaxbElement

I have jaxb Class , in which when attribute is defined as below then value is loaded in list:

    @XmlElementRef(name = "mainElement", namespace = "http://www.xyz.org/spec/524/MODELS", type = JAXBElement.class)
   protected List<JAXBElement<? extends MainElement>> mainElement; 

when attribute is defined as below then value is not loaded in list(null contains) :

    @XmlElement(name = "mainElement")
 protected List<MainElement> mainElement;

Is there a way to remove JAXBElement from java class generated from xsd .

You can use xjc to generate your classes and if you don't like how they are generating you can change them using an bindings file. See this stack question and answer for more info. jaxb xjc mapping

Also, this blog is really helpful from Blaise Doughan. http://blog.bdoughan.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM