users@jaxb.java.net

Re: XML content within an element

From: Zhidong Zhao <zzhao_at_CS.UNO.EDU>
Date: Thu, 20 Feb 2003 01:04:50 -0700

This sounds good, but I got a question: After you have the content object, how do you pass it to a remote client? i.e. not in the same jvm. The content element that jaxb generated is not serializable. Of cause we can marshal the content into xml stream and transmit the stream via http, but we need to unmarshal it at the client side. In my case, the content object contains references to other elements. The marshalled xml stream is not a closed context. Though I have replicates of those elements in the client machine, I can not link the references with othse elements. Is there any solution to this problem? The way I deal it is to reassambly the xml fragment with other xml parts passed earlier so that the entire xml stream comforms to its schema. Then unmarshal the entire xml and retrieve the content element at the client side. What a waist of time and resources.
Can any body point out a wiser way to deal with it? My goal is just to transfer a serializable object.

<Kohsuke.Kawaguchi_at_Sun.COM> wrote:

>Assuming that the "XXXX" part is defined as an wildcard, I think JAXB
>will do the right thing by default. You'll get something like:
>
> public interface Event {
> String getType();
> String getVersion();
> javax.xml.bind.Element getContent();
> }
>
>where the getContent method will return the object unmarshalled from XXX
>part. So your core module can just inspect the Event object and then
>dispatch its content to the customer module, and the customer module can
>cast it to another generated interface and take it from there.