users@jaxb.java.net

_at_XmlRootElement repeats elements in Schema

From: Alex Sherwin <alex.sherwin_at_acadiasoft.com>
Date: Fri, 24 Oct 2008 15:56:47 -0400

Hello,
I've got some classes which can all be marshalled individually, and as such
all have an @XmlRootElement annotation.

However, when I want to use these classes as part of a larger object, i.e.
 "MessageWrapper" which has an @XmlRootElement annotation and contains three
List<> properties, each of which is a list of a JAXB annotated class that
has an @XmlRootElement.

Technically this all works just fine, but if I generate the schema for
MessageWrapper, the messageWrapper element is not the only root element of
the schema. All JAXB @XmlRootElement annotated objects that get marshalled
at some point (even though they are all properties of the class I'm
generating the Schema for) are also root elements in the resulting schema.

If I remove the @XmlRootElement annotation from all classes which are being
used within MessageWrapper, the resulting schema is as expected (only one
messageWrapper) root element.

How can I make these elements not be root elements of MessageWrapper's
Schema, but can still be individually marshalled?

-- 
Alexander Sherwin