Search in sources :

Example 36 with TransformerHandler

use of javax.xml.transform.sax.TransformerHandler in project tika by apache.

the class TikaGUI method getXmlContentHandler.

private ContentHandler getXmlContentHandler(Writer writer) throws TransformerConfigurationException {
    SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
    TransformerHandler handler = factory.newTransformerHandler();
    handler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
    handler.setResult(new StreamResult(writer));
    return handler;
}
Also used : TransformerHandler(javax.xml.transform.sax.TransformerHandler) StreamResult(javax.xml.transform.stream.StreamResult) SAXTransformerFactory(javax.xml.transform.sax.SAXTransformerFactory)

Aggregations

TransformerHandler (javax.xml.transform.sax.TransformerHandler)36 StreamResult (javax.xml.transform.stream.StreamResult)25 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)22 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)13 StringWriter (java.io.StringWriter)10 Transformer (javax.xml.transform.Transformer)9 SAXException (org.xml.sax.SAXException)9 AttributesImpl (org.xml.sax.helpers.AttributesImpl)9 InputStream (java.io.InputStream)7 Metadata (org.apache.tika.metadata.Metadata)7 ParseContext (org.apache.tika.parser.ParseContext)5 File (java.io.File)4 IOException (java.io.IOException)4 TikaTest (org.apache.tika.TikaTest)4 AutoDetectParser (org.apache.tika.parser.AutoDetectParser)4 Test (org.junit.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 OutputStream (java.io.OutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3 Parser (org.apache.tika.parser.Parser)3