April 15, 2011

@XmlAnyElement and non-DOM Properties

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

JAXB and JSON via Jettison - Namespace Example

In a previous post I described how Jettison can be leveraged by a JAXB implementation to produce/consume JSON.  A reader correctly pointed out that I did not describe how to handle namespaces.  Since JSON does not support namespaces you would not normally include them in your mappings.  However if you wanted to map your object model to both JSON and XML with namespaces, this post will demonstrate how it can be done.

XML Schema to Java - XSD Choice

In a previous blog post I wrote about how to map to the choice structure in XML schema when starting from classes.  An astute reader tried generating an object model from that schema and noticed that the JAXB implementation generated something different than expected.  In this post I'll explain the difference.

April 12, 2011

JAXB and JSON via Jettison

JAXB implementations (Metro, EclipseLink MOXy, Apache JaxMe, etc) provide an easy means of converting objects to/from XML.  There is a library called Jettison that exposes access to JSON messages via the StAX API that a JAXB implementation can use to convert objects to/from JSON.  This library is being leveraged by a number of JAX-RS implementations.  In this post I'll demonstrate its use in a standalone example.

April 11, 2011

MOXy's XML Metadata in a JAX-RS Service

In previous posts I introduced how EclipseLink JAXB (MOXy) can represent it's metadata as XML, and how MOXy can be used in a JAX-RS service.  In this post I'll demonstrate how to leverage MOXy's metadata file in a JAX-RS service by using a ContextResolver.