users@jaxb.java.net

Re: Marshalling and unmarshalling to several root elements

From: Ryan Shoemaker - JavaSoft East <Ryan.Shoemaker_at_sun.com>
Date: Wed, 07 May 2003 14:03:49 -0400

R?zs?s L?szl? wrote:
> Hi,
>
> I have an XML schema with a root element called for example <cars>,
> that can contain several <car> tags, that in turn contain the description
> of a car. In some cases I only need the description of one car, so I'd
> like to get an XML file that contains only one <car> tag as its root
> element, but in some other cases I need the complete list of cars with
> their descriptions, so I'd like to generate an XML file with a <cars> tag
> as root element. How can I do that in JAXB?
>

I'm reading Laszlo's question differently than Kohsuke and Han Ming.

I could be wrong, but I think he's asking if he has the choice between
marshalling the entire tree (resulting in a <cars> root element) and
marshalling a portion of the tree (resulting in a <car> root element).

Laszlo, can you clarify?

Thanks,

--Ryan

> Example 1:
>
> <cars>
> <car>
> <type></type>
> </car>
> <car>
> <type></type>
> </car>
> <car>
> <type></type>
> </car>
> .....
> </cars>
>
> Example 2:
>
> <car>
> <type></type>
> </car>
>
> Thanks,
>
> Laszlo Rozsas