1 19 package org.openharmonise.rm.publishing.renderers.impl; 20 21 import java.io.*; 22 23 import javax.xml.transform.*; 24 import javax.xml.transform.dom.*; 25 import javax.xml.transform.stream.*; 26 27 import org.openharmonise.commons.xml.*; 28 import org.openharmonise.rm.publishing.renderers.*; 29 30 31 32 40 public class StandardRenderer implements PageRenderer { 41 42 45 public StandardRenderer() { 46 super(); 47 } 48 49 52 public void render(XMLDocument xdoc, Templates templates, OutputStream out) 53 throws RenderException { 54 try { 55 OutputStreamWriter outwriter = new OutputStreamWriter(out,"UTF-8"); 56 57 Transformer trans = templates.newTransformer(); 58 59 DOMSource ds = new DOMSource(xdoc.getDocumentElement()); 60 61 StreamResult res = new StreamResult(outwriter); 62 63 trans.transform(ds, res); 64 } catch (TransformerConfigurationException e) { 65 throw new RenderException("Error occured with configuration",e); 66 } catch (TransformerException e) { 67 throw new RenderException("Error occured with transformation",e); 68 } catch (UnsupportedEncodingException e) { 69 throw new RenderException("Unsupported encoding error",e); 70 } 71 } 72 } 73 | Popular Tags |