Hello Joe, Morris, Charles,
Thank you for your prompt reply as well as kind suggestions. The following
is
how I did and it works. Please take a look and see if there is any other way
I can do it better or improve the code. Otherwise, please feel free to use
it
as well. Once again, THANK YOU, all.
Regards,
Pae
// ############### Code Snippet ####################
public StreamSource convertXMLDoc2StreamSource(Document xmlDoc) {
StreamSource streamSource = null;
<Snip>
DOMSource domSource = new DOMSource( xmlDoc );
StreamResult streamResult = new StreamResult( new
java.io.ByteArrayOutputStream() );
try {
Transformer transformer =
TransformerFactory.newInstance().newTransformer();
transformer.transform( domSource, streamResult );
}
catch (Exception ex) { //
javax.xml.transform.TransformerException
ex.printStackTrace();
}
OutputStream os = streamResult.getOutputStream();
ByteArrayOutputStream baos = (ByteArrayOutputStream)os;
InputStream is = new ByteArrayInputStream( baos.toByteArray() );
streamSource = new StreamSource( is );
</Snip>
return streamSource;
}