Showing posts with label XmlAnyElement. Show all posts
Showing posts with label XmlAnyElement. Show all posts

December 21, 2012

JAXB's @XmlAnyElement(lax=true) Explained

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.

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.

February 11, 2012

Mapping an Arbitrary List of Objects using JAXB's @XmlAnyElement and XmlAdapter

The @XmlAnyElement annotation enables a property to handle arbitrary XML elements, and the XmlAdapter provides a way to convert an object that can not be mapped into one that can.  In this post we will combine these two mechanisms  to map a list of arbitrary objects.

This post will cover the following concepts:
  1. The @XmlAnyElement annotation
  2. A type level XmlAdapter
  3. Marshalling/Unmarshalling root level simple data types (i.e. String and Integer)
  4. Specifying a root element via JAXBElement
  5. Specifying the type to be unmarshalled on the Unmarshaller

April 15, 2011

@XmlAnyElement and non-DOM Properties

This post will cover how to use an alternate DOM representation (i.e. String) with @XmlAnyElement.

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.