At 17:04 +0000 03/08/00, Pedro E. Gómez wrote:
>I have create a new XML document object using DocumentImpl (is this the
>way to do that) and I have populated the document but I do not know how to
>save it in a File.
this is some code adapted from the FP Tagset
it may or may not be the ideal way of doing it
you pass this the Document object and the char encoding it is in.
public void save(Document workDoc, String workEncoding) {
OutputFormat format = new OutputFormat(workDoc, workEncoding, true);
format.setVersion("1.0");
// most of this lot is probably not required
format.setPreserveSpace(true);
format.setIndent(1);
format.setIndenting(true);
format.setLineWidth(0);
format.setLineSeparator("\n");
try {
FileWriter writer = new FileWriter(workFile);
Serializer serializer = serializer_factory.makeSerializer(writer,format);
serializer.asDOMSerializer().serialize(workDoc);
writer.close();
} catch (Exception ex) {
[snip]
}
}
You can find the rest of the source code in the dist for Cocoon 1.8 at
/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/fp/
Hope this helps
--
___________________________________________________________________
Jeremy Quinn Karma Divers
webSpace Design
HyperMedia Research Centre
<mailto:sharkbait@mac.com> <http://www.media.demon.co.uk>
<phone:+44.[0].20.7737.6831> <pager:jermq@sms.genie.co.uk>
|