Best code examples for Java 8 TransformerFactory class (javax.xml.transform.TransformerFactory)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 TransformerFactory class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 TransformerFactory examples from Open Source projects
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
This code example shows how to use the following methods: setErrorListener, setURIResolver
	 * Initialize this XsltView's TransformerFactory. 
	 */ 
	@Override 
	protected void initApplicationContext() throws BeansException { 
		this.transformerFactory = newTransformerFactory(this.transformerFactoryClass); 
		this.transformerFactory.setErrorListener(this.errorListener); 
		if (this.uriResolver != null) { 
			this.transformerFactory.setURIResolver(this.uriResolver); 
		} 
		if (this.cacheTemplates) { 
			this.cachedTemplates = loadTemplates(); 
		} 
	} 
 
	/** 
	 * Instantiate a new TransformerFactory for this view. 
	 * <p>The default implementation simply calls 
	 * {@link javax.xml.transform.TransformerFactory#newInstance()}. 
	 * If a {@link #setTransformerFactoryClass "transformerFactoryClass"} 
	 * has been specified explicitly, the default constructor of the 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: newTransformer
	 * @param source the source to transform from 
	 * @param result the result to transform to 
	 * @throws TransformerException in case of transformation errors 
	 */ 
	protected void transform(Source source, Result result) throws TransformerException {
		this.transformerFactory.newTransformer().transform(source, result);
	} 
 
 
	/** 
	 * Abstract template method called from {@link #read(Class, HttpInputMessage)}. 
	 * @param clazz the type of object to return 
	 * @param headers the HTTP input headers 
	 * @param source the HTTP input body 
	 * @return the converted object 
	 * @throws IOException in case of I/O errors 
	 * @throws org.springframework.http.converter.HttpMessageConversionException in case of conversion errors 
	 */ 
	protected abstract T readFromSource(Class<? extends T> clazz, HttpHeaders headers, Source source)
			throws IOException;
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getFeature, setAttribute, setErrorListener, setURIResolver
    if (uriResolver == null) {
      throw new RuntimeException("uriResolver property must be set");
    } 
    TransformerFactory tFactory = TransformerFactory.newInstance();
    setFactoryResolver(tFactory);
    tFactory.setAttribute("http://xml.apache.org/xalan/features/incremental", java.lang.Boolean.TRUE);
 
    if (tFactory.getFeature(SAXSource.FEATURE) && tFactory.getFeature(SAXResult.FEATURE)) {
      // Cast the TransformerFactory to SAXTransformerFactory. 
      saxTFactory = ( (SAXTransformerFactory) tFactory);
    } 
    if (outputProperties == null) {
      outputProperties = OutputPropertiesFactory.getDefaultMethodProperties("html");
    } 
    templateCache = new ConcurrentHashMap<String, Templates>();
 
  } 
 
  protected void setFactoryResolver(TransformerFactory tFactory) {
    if (uriResolver == null) {

6
CodeRank
This code example shows how to use the following methods: newTemplates, setErrorListener, setURIResolver
    @Before 
    public void setup() throws Exception {
        final ResourceLoaderURIResolver resolver = new ResourceLoaderURIResolver(new ClassRelativeResourceLoader(getClass()));
         
        this.tFactory = TransformerFactory.newInstance();
        this.tFactory.setURIResolver(resolver);
        this.tFactory.setErrorListener(new SimpleTransformErrorListener(LogFactory.getLog(getClass())));
         
        //Load the XML document so it reads the same way the rendering pipeline reads XML 
        final XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
        final XMLEventReader eventReader = xmlInputFactory.createXMLEventReader(this.getClass().getResourceAsStream("test.xml"));
        final XMLStreamReader streamReader = new FixedXMLEventStreamReader(eventReader);
        xmlSource = new StAXSource(streamReader);
         
        xslTemplate = tFactory.newTemplates(new StreamSource(this.getClass().getResourceAsStream("test.xsl")));
         
        expected = IOUtils.toString(this.getClass().getResourceAsStream("result.xml"));
    } 
     
    @Test
Full Snippet Info
6
CodeRank
Related Java 8 TransformerFactory Questions & Answers:
See Code Examples for Java 8 TransformerFactory Methods: