Java 8 SAXTransformerFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SAXTransformerFactory class.

This code example shows how to use the following methods:getErrorListener, newTemplates, setErrorListener, setURIResolver
	throws TransformerConfigurationException { 
        if (_xsltcFactory == null) {
            createXSLTCTransformerFactory(); 
        } 
	if (_errorlistener != null) {
	    _xsltcFactory.setErrorListener(_errorlistener);	    
	} 
	if (_uriresolver != null) {
	    _xsltcFactory.setURIResolver(_uriresolver);
	} 
	Templates templates = _xsltcFactory.newTemplates(src);
	if (templates == null ) return null;
	return newXMLFilter(templates); 
    } 
 
    /* 
     * Create an XMLFilter that uses the given source as the 
     * transformation instructions. Uses 
     * org.apache.xalan.xsltc.trax.TransformerFactory. 
     */ 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:newTransformerHandler
		parser = new Parser();
	} 
 
	@Override 
	public Node readXML(String uri) throws Exception {
		TransformerHandler handler = saxFactory.newTransformerHandler();
		DOMResult result = new DOMResult();
		handler.setResult(result);
		parser.setContentHandler(handler);
		parser.parse(getInputSource(uri));
		return result.getNode();
	} 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:newTemplatesHandler, newTransformerHandler
        super.setXMLConsumer(new XMLConsumerAdapter(transformerHandler, transformerHandler));
    } 
 
    private TransformerHandler createTransformerHandler() throws Exception {
        SAXTransformerFactory transformerFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
        TemplatesHandler templatesHandler = transformerFactory.newTemplatesHandler();
 
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();
        xmlReader.setContentHandler(templatesHandler);
        InputSource inputSource = new InputSource(getXsltSource());
        xmlReader.parse(inputSource);
 
        // Create transformer handler 
        final TransformerHandler handler = transformerFactory.newTransformerHandler(templatesHandler.getTemplates());
 
        return handler;
    } 
 
    private Map<String, Object> getLogicSheetParameters() {
        if (this.parameters == null) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getErrorListener, newTemplates, setErrorListener, setURIResolver
	throws TransformerConfigurationException { 
        if (_xsltcFactory == null) {
            createXSLTCTransformerFactory(); 
        } 
	if (_errorlistener != null) {
	    _xsltcFactory.setErrorListener(_errorlistener);	    
	} 
	if (_uriresolver != null) {
	    _xsltcFactory.setURIResolver(_uriresolver);
	} 
	Templates templates = _xsltcFactory.newTemplates(src);
	if (templates == null ) return null;
	return newXMLFilter(templates); 
    } 
 
    /* 
     * Create an XMLFilter that uses the given source as the 
     * transformation instructions. Uses 
     * org.apache.xalan.xsltc.trax.TransformerFactory. 
     */ 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAssociatedStylesheet, newTransformer
        // 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(realPath);
            final Source associatedStylesheet = transformerFactory.getAssociatedStylesheet(streamSource,
                    null, null, null); 
            if (associatedStylesheet == null) {
                return null; 
            } 
 
            transformer = transformerFactory.newTransformer(associatedStylesheet);
        } catch (TransformerConfigurationException e) {
            log.info("Can't create transformer: " + e.getMessage()); //ignored
        } 
        return transformer;
    } 
 
    private XMLReader createReader() throws ParserConfigurationException, SAXException {
        final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:newTransformerHandler
        // rtfSample.write(System.out); 
 
        // Prepare a SAX content handler 
        SAXTransformerFactory factory = ((SAXTransformerFactory) TransformerFactory
                .newInstance());
        TransformerHandler transform = factory.newTransformerHandler();
        transform.setResult(new StreamResult(System.out));
 
        // Analyze the RTF representation 
        TikaRepresentation tr = new TikaRepresentation(rtfSample);
        tr.setTikaParser(new RTFParser());
        tr.parse(transform);
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setErrorListener, setURIResolver, newTransformerHandler
    { 
        if (_xalanFactory == null) {
            createXalanTransformerFactory(); 
        } 
	if (_errorlistener != null) {
	    _xalanFactory.setErrorListener(_errorlistener);	    
	} 
	if (_uriresolver != null) {
	    _xalanFactory.setURIResolver(_uriresolver);
	} 
	return _xalanFactory.newTransformerHandler(); 
    } 
 
    /** 
     * Get a TransformerHandler object that can process SAX ContentHandler 
     * events based on a transformer specified by the stylesheet Source.  
     * Uses org.apache.xalan.processor.TransformerFactory.  
     */ 
    public TransformerHandler newTransformerHandler(Source src) 
	throws TransformerConfigurationException 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:newTransformerHandler
This code example shows how to use the following methods:newTransformerHandler
        } 
 
        StringWriter output = new StringWriter();
 
        SAXTransformerFactory stf = (SAXTransformerFactory) tf;
        TransformerHandler th = stf.newTransformerHandler();
        th.setResult(new StreamResult(output));
 
        XMLStreamWriter writer = StAXUtils.getXMLStreamWriter(new SAXResult(th));
 
        writer.writeStartElement("element");
        writer.writeAttribute("attribute", "value");
        writer.writeCharacters("characters");
        writer.writeCData("cdata");
        writer.writeEndElement();
 
        Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<element attribute=\"value\">"
            + "characters" + "<![CDATA[cdata]]>" + "</element>", output.getBuffer().toString());
    } 
 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:newTransformerHandler
	public XmlWriter(PrintWriter out) throws SAXException {
		try { 
			StreamResult streamResult = new StreamResult(out);
			SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance();
			// SAX2.0 ContentHandler. 
			hd = tf.newTransformerHandler();
			Transformer serializer = hd.getTransformer();
			serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
			// serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd"); 
			serializer.setOutputProperty(OutputKeys.INDENT, "yes");
			hd.setResult(streamResult);
			hd.startDocument();
		} catch (Exception e) {
			throw new SAXException("Unexpected error in XML initialization", e);
		} 
	} 
 
	public void close() throws SAXException {
		hd.endDocument();
	} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 SAXTransformerFactory Methods: