01: /*
02: * The contents of this file are subject to the
03: * Mozilla Public License Version 1.1 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
06: *
07: * Software distributed under the License is distributed on an "AS IS"
08: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
09: * See the License for the specific language governing rights and
10: * limitations under the License.
11: *
12: * The Initial Developer of the Original Code is Simulacra Media Ltd.
13: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14: *
15: * All Rights Reserved.
16: *
17: * Contributor(s):
18: */
19: package org.openharmonise.rm.publishing.renderers.impl;
20:
21: import java.io.*;
22:
23: import javax.xml.transform.*;
24:
25: import org.openharmonise.commons.xml.*;
26: import org.openharmonise.commons.xml.namespace.*;
27: import org.openharmonise.rm.publishing.renderers.*;
28:
29: /**
30: *
31: * FIXME - Michael Bell DIDN'T GIVE ME A DESCRIPTION!!
32: * @author Michael Bell
33: * @version $Revision: 1.2 $
34: *
35: */
36: public class TextRenderer implements PageRenderer {
37:
38: private static XMLPrettyPrint m_xprinter = new XMLPrettyPrint();
39:
40: /**
41: * Basic constructor
42: */
43: public TextRenderer() {
44: super ();
45: }
46:
47: /* (non-Javadoc)
48: * @see org.openharmonise.rm.publishing.renderers.PageRenderer#render(org.openharmonise.commons.xml.XMLDocument, javax.xml.transform.Templates, java.io.OutputStream)
49: */
50: public void render(XMLDocument xdoc, Templates templates,
51: OutputStream out) throws RenderException {
52:
53: try {
54: PrintStream pstream = new PrintStream(out, true, "UTF-8");
55:
56: pstream.print(m_xprinter.printNode(xdoc
57: .getDocumentElement()));
58: pstream.flush();
59: } catch (NamespaceClashException e) {
60: throw new RenderException("There was a namespace clash?!",
61: e);
62: } catch (UnsupportedEncodingException e) {
63: throw new RenderException("Unsupported char encoding", e);
64: }
65:
66: }
67:
68: /**
69: * Renders state to <code>OutputStream</code>
70: *
71: * @param out
72: * @throws RenderException
73: */
74: static public void render(XMLDocument xdoc, OutputStream out)
75: throws RenderException {
76: try {
77: PrintStream pstream = new PrintStream(out, true, "UTF-8");
78:
79: pstream.print(m_xprinter.printNode(xdoc
80: .getDocumentElement()));
81: pstream.flush();
82: } catch (NamespaceClashException e) {
83: throw new RenderException("There was a namespace clash?!",
84: e);
85: } catch (UnsupportedEncodingException e) {
86: throw new RenderException("Unsupported char encoding", e);
87: }
88:
89: }
90:
91: }
|