The easiest way would be to create a schema for each type of XML
instance document you're going to send to the client, bind each schema
to Java objects (using the jaxb xjc compiler), populate and manipulate
those objects as necessary, and marshal the tree into a String that you
send to your client.
To marshal a Java object graph into a String create and pass a
java.io.StringWriter object as argument #2 to the marshal() method of
the javax.xml.bind.Marshaller.
All of this assumes that this is an "all Java" scenario, which begs the
question, "Why are you using XML as a wire format, instead of a
serialized java object?"
hth
-----Original Message-----
From: Tony Yau [mailto:tony.yau_at_emigen.co.uk]
Sent: Tuesday, June 01, 2004 11:06 AM
To: users_at_jaxb.dev.java.net
Subject: marshal xml to multiple clients
Hi,
I need to send xml data to multiple socket clients. What is the most
efficient way with jaxb?
say:
1) marshal to a DOM object and send its Document object through an
outputter to OutputStreams for the socket clients? This way I can
generate event with the Document object and leave the marshaller for the
next xml data.
2) or just call the marshaller multiple times with the OutputStreams
as arg for each clients, but then the marshaller is tied up until all
the clients gets the data.
Is there a way to marshal the xml to a String object?
emigen