Code example for TransformerFactory

Methods: newTransformer

0
    } 
     
    public void testSaxonExt() throws Exception { 
        Class clazz = Class.forName("net.sf.saxon.TransformerFactoryImpl");
        TransformerFactory factory = (TransformerFactory)clazz.newInstance();
        Transformer trans = factory.newTransformer(new StreamSource(
                new File(getBaseDir(), "src/saxon8/test/xml/saxon8-test.xsl")));
        Source src = new StreamSource(
                new File(getBaseDir(), "src/test/xml/xslt-test.xml"));
        StringWriter writer = new StringWriter();
        Result res = new StreamResult(writer);
         
        trans.transform(src, res);
        String output = writer.getBuffer().toString();
        assertTrue(output.indexOf("svg") >= 0);
        //System.out.println(writer.getBuffer()); 
    } 
 
}