Code example for SAXTransformerFactory

Methods: newTransformerHandler

0
        private AttributesStack attributesStack = new AttributesStack();
 
        public Filter() throws Exception { 
            SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance();
 
            handler = tf.newTransformerHandler();
            Transformer serializer = handler.getTransformer();
 
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "no");
 
            OutputStream out = new FileOutputStream(destfile);
            StreamResult streamResult = new StreamResult(out);
 
            handler.setResult(streamResult);
        } 
 
        @Override 
        public void characters(char[] ch, int start, int length) throws SAXException {
            String content = new String(ch, start, length);
Experience pair programming with AI  Get Codota for Java