Return-Path: Delivered-To: apmail-xml-xalan-j-users-archive@xml.apache.org Received: (qmail 81228 invoked by uid 500); 11 Oct 2002 04:52:21 -0000 Mailing-List: contact xalan-j-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list xalan-j-users@xml.apache.org Received: (qmail 81195 invoked from network); 11 Oct 2002 04:52:21 -0000 Received: from albatross.mail.pas.earthlink.net (HELO albatross.prod.itd.earthlink.net) (207.217.120.120) by daedalus.apache.org with SMTP; 11 Oct 2002 04:52:21 -0000 Received: from 1cust113.tnt2.williamsburg.va.da.uu.net ([67.201.74.113] helo=dev1) by albatross.prod.itd.earthlink.net with smtp (Exim 3.33 #1) id 17zrmn-0004BJ-00; Thu, 10 Oct 2002 21:52:30 -0700 Message-ID: <009701c270fb$077bc7d0$0b01a8c0@dev1> From: "Pae Choi" To: , , "Joseph Kesselman" , , "Crook, Charles" References: Subject: Re: DOM to StreamSource Date: Fri, 11 Oct 2002 00:49:48 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Status: O X-Status: X-Keywords: 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; 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 ); return streamSource; }