Code example for SAXTransformerFactory

Methods: getAssociatedStylesheetnewTransformer

        // use system property javax.xml.transform.TransformerFactory to define special factory  (e.g. net.sf.saxon.TransformerFactoryImpl) 
        Transformer transformer = null;
        try { 
            final SAXTransformerFactory transformerFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
            final StreamSource streamSource = new StreamSource(new ByteArrayInputStream(source.getBytes()));
            final Source associatedStylesheet = transformerFactory.getAssociatedStylesheet(streamSource,
                    null, null, null); 
            if (associatedStylesheet == null) {
                return null; 
            transformer = transformerFactory.newTransformer(associatedStylesheet);
        } catch (TransformerConfigurationException e) {
  "Can't create transformer: " + e.getMessage()); //ignored
        return transformer;
    private XMLReader createReader() throws ParserConfigurationException, SAXException {
        final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
Connect your IDE to all the code out there  Get Codota for Java