1 16 package org.apache.cocoon.serialization; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.configuration.ConfigurationException; 20 import org.apache.cocoon.CascadingIOException; 21 import javax.xml.transform.OutputKeys ; 22 import javax.xml.transform.sax.TransformerHandler ; 23 import javax.xml.transform.stream.StreamResult ; 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 27 45 46 public class HTMLSerializer extends AbstractTextSerializer { 47 48 51 public void configure(Configuration conf) 52 throws ConfigurationException { 53 super.configure(conf); 54 this.format.put(OutputKeys.METHOD,"html"); 55 } 56 57 61 public void setOutputStream(OutputStream out) 62 throws IOException { 63 super.setOutputStream(out); 64 try { 65 TransformerHandler handler = this.getTransformerHandler(); 66 handler.getTransformer().setOutputProperties(this.format); 67 handler.setResult(new StreamResult (this.output)); 68 this.setContentHandler(handler); 69 this.setLexicalHandler(handler); 70 } catch (Exception e) { 71 final String message = "Cannot set HTMLSerializer outputstream"; 72 throw new CascadingIOException(message, e); 73 } 74 } 75 } 76 | Popular Tags |