users@jaxb.java.net

RE: Multiple objects which are root elements in the same package

From: Touve, Larry E \(US SSA\) <"Touve,>
Date: Fri, 17 Apr 2009 10:38:56 -0700

Alan,

As far as marshalling an object that's not a root element, check out:
http://weblogs.java.net/blog/kohsuke/archive/2005/10/101_ways_to_mar.htm
l

HTH,
 larry

-----Original Message-----
From: Alan Chaney [mailto:alan_at_muzlink.com]
Sent: Friday, April 17, 2009 12:05 PM
To: users_at_jaxb.dev.java.net
Subject: Multiple objects which are root elements in the same package

Hi

This is a complete newb question. I've just started using Jaxb 2.1 and
am very impressed. I'm trying to use jaxb to marshal/unmarshal a number
of objects where under certain circumstances different objects in the
object graph are the root element.

A simple illustration for objects A, B and C where

A has a list of B
and B has a list of C

is that in some cases I want A to be the root, some cases B to be the
root and some cases C to be the root.

Experimentation indicates that simply setting @XMLRootElement
annotations in the classes A B and C works.

The problem is that if I regenerate the schema using xjc only the 'root'

element of the schema gets that annotation.

Is there any easy way to organize or indicate within the schema that A B

and C should all be marked with @XmlRootElement so I don't have to keep
manually editing the source files after compilation?

Once again, I apologize if the answer is obvious in the docs but I
couldn't find it.

Thanks in advance

Alan Chaney


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net