In a previous post I introduced how the @XmlAnyElement(lax=true) annotation could be used to create a very flexible mapping. In this post I'll dig a bit deeper into how it relates to both the @XmlRootElement and @XmlElementDecl.
Showing posts with label XmlRootElement. Show all posts
Showing posts with label XmlRootElement. Show all posts
December 21, 2012
JAXB's @XmlAnyElement(lax=true) Explained
Labels:
JAXB,
XmlAnyElement,
XmlElementDecl,
XmlRootElement
November 15, 2012
Creating a Generic List Wrapper in JAXB
To marshal/unmarshal a list with a JAXB (JSR-222) implementation you need to create a wrapper object to hold the list. People find this onerous having to create multiple wrapper objects for this purpose. Below I'll demonstrate that in reality you only need to create one. This post is based on an answer I gave on Stack Overflow.
Labels:
Collection Property,
JAXB,
XmlAnyElement,
XmlRootElement
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.
Labels:
JAXB,
JAXBIntrospector,
XmlElementDecl,
XmlRootElement
March 9, 2011
Handling Duplicate @XmlRootElement Declarations
The following post was inspired by an answer I gave to a question on Stack Overflow (feel free to up vote). The problem arose from a JAXBContext being created on classes derived from two schemas that both use the same root element. The solution is to supply type of object to the unmarshal operation.
November 4, 2010
JAXB and Inheritance - Using Substitution Groups
In a previous blog post I described how to leverage the xsi:type attribute to represent inheritance. In this post I'll demonstrate how to use the element name instead by leveraging the XML Schema concept of substitution groups.
Labels:
Inheritance,
JAXB,
XmlElementRef,
XmlRootElement
August 26, 2010
Using @XmlAnyElement to Build a Generic Message
In this post we are building our own XML messaging framework. We want to have a standard message object (similar to a SOAP envelope) that the framework can understand, and the ability to easily add domain specific payloads over time.
Subscribe to:
Posts (Atom)