Posts

Showing posts from June, 2013

Jaxb not adding the @XMLRoot element.

There are those cases where you are trying to build an object Model from XSD and sees that there is no @XMLRootElement tag added to the root element in the stub and your unmarshelling starts failing. The    basic idea is that if we can statistically guarantee that a complex type won't be used by multiple different tag names, XJC put @XmlRootElement.  Try for the basic schema  http://www.w3schools.com/schema/  here. You see the root element gets generated. The issue happens when you have something like this <schema>   <element name = "Employee" type = "inc:CTEmployee" />   <complexType name = "CTEmployee" /> </schema>   You see the Employee element is not tagged with the @XMlRootElement in the stub. The Assumption that XJC does is  that  "your schema might be used by other schema's that XJC isn't compiling right now" . So basic fix is avoid doing the Complex type defined ou...