Showing posts with label JAXBIntrospector. Show all posts
Showing posts with label JAXBIntrospector. Show all posts

July 31, 2012

JAXB and Root Elements

@XmlRootElement is an annotation that people are used to using with JAXB (JSR-222).  It's purpose is to uniquely associate a root element with a class.  Since JAXB classes map to complex types, it is possible for a class to correspond to multiple root elements. In this case @XmlRootElement can not be used and people start getting a bit confused.  In this post I'll demonstrate how @XmlElementDecl can be used to map this use case.