users@jaxb.java.net

Re: XML content within an element

From: mike gabelmann <mike.gabelmann_at_krucible.com>
Date: Thu, 20 Feb 2003 08:20:58 -0800

There is the facility within Java 1.4 to serialize a Java object as XML
using the XMLEncoder and Decoder class. You just have to make sure that your
object qualifies as a bean and implements Serializable interface.


-----Original Message-----
From: Discussion list for the Java Architecture for XML Binding
[mailto:JAXB-INTEREST_at_JAVA.SUN.COM]On Behalf Of Joe Fialli
Sent: Thursday, February 20, 2003 5:46 AM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: XML content within an element


Zhidong Zhao wrote:
> 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.

The final version of JAXB reference implementation has an implementation
specific customization extension that enables java serialization to be
turned on. The JAXB specification could not specify serialization since
it would have had to specify how different JAXB implementations would
interoperate via serialization, an impossible task when the JAXB
binding framework mechanism has not been standardized across
implementations.
(A task that was pushed off for a future release).

-Joe Fialli, Sun Microsystems

>
> <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.
>


--