Jaxb API - Remove JaxbElement

1k Views Asked by At

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 .

1

There are 1 best solutions below

0
On

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/