users@jaxb.java.net

RE: Extensible soutions using JAXB?

From: Ernst, Matthias <matthias.ernst_at_coremedia.com>
Date: Thu, 24 May 2007 11:00:33 +0200

> I have asked this before and I'm still hunting a solution.... If an
> unexpected element is added to the XML content, how can I use JAXB to
> handle this?

Andrew,

implementing Atom :-) ?

You can annotate a field like this:

@XmlAnyElement @XmlElementRef
public List<Object> extensionElements;

It will collect
* known root elements (classes with @XmlRootElement) as unmarshalled
objects (due to @XmlElementRef)
* all other (unknown) elements as DOM nodes.

Pretty neat IMHO.

Matthias

-- 
matthias.ernst_at_coremedia.com
software architect
+49.40.32 55 87.503