users@jaxb.java.net

Marshalling and unmarshalling to several root elements

From: Rózsás László <rozsas_at_sztaki.hu>
Date: Wed, 07 May 2003 12:07:52 +0200

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?

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