This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: dumb question:
- To: xsl-list at mulberrytech dot com
- Subject: Re: dumb question:
- From: Warren Hedley <w dot hedley at auckland dot ac dot nz>
- Date: Tue, 04 Apr 2000 12:15:10 +1200
- Organization: Department of Engineering Science, The University of Auckland
- References: <8B6B6EFD42F9D311BAD7005004A426D0032FC0@BSSVANMAIL>
- Reply-To: xsl-list at mulberrytech dot com
"Narahari, Sateesh" wrote:
>
> using the DOM model, you can easily make an XML document. However, saving it
> to a file will be a big pain , since AFAIK, only MSXML parser supports Save
> method.
Actually you can use something like xalan's TreeWalker in combination with
their FormatterToXML to output XML from DOM. Here's some sample code, which
is just the relevant bits that I've ripped out of one of my projects -
untested as is!
import org.apache.xalan.xpath.xml.FormatterToXML;
import org.apache.xalan.xpath.xml.TreeWalker;
FormatterToXML xmlFormatter = null;
TreeWalker treeWalker = null;
xmlFormatter = new FormatterToXML(System.out);
xmlFormatter.indent = 2;
treeWalker = new TreeWalker(xmlFormatter);
Document document;
// construct the document
treeWalker.traverse(document);
xmlFormatter.flush();
Hope this helps.
--
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list