Java 8 Templates - 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 Templates class.

This code example shows how to use the following methods:newTransformer
					s = ERXFileUtilities.stringFromInputStream(is);
					s = templateParser.parseTemplateWithObject(s, "@@", app);
					t = fac.newTemplates(new StreamSource(new ByteArrayInputStream(s.getBytes())));
 
					if (app.isCachingEnabled()) {
						templates.put(key, t);
					} 
				} catch (IOException e1) {
					throw NSForwardException._runtimeExceptionForThrowable(e1);
				} catch (TransformerConfigurationException tce) {
					log.error("could not create template " + tce.getLocationAsString(), tce);
					log.error("  cause", tce.getCause());
					if (tce.getCause() != null && tce.getCause() instanceof org.xml.sax.SAXParseException) {
						org.xml.sax.SAXParseException e = (org.xml.sax.SAXParseException) tce.getCause();
						log.error("SAXParseException: line " + e.getLineNumber() + ", column " + e.getColumnNumber());
					} 
					log.error("this is the incorrect xsl:>>>" + s + "<<<");
					return null; 
				} 
			} 

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:newTransformer
	 * @param templates the XSLT Templates instance to create a Transformer for 
	 * @return the Transformer object 
	 * @throws TransformerConfigurationException in case of creation failure 
	 */ 
	protected Transformer createTransformer(Templates templates) throws TransformerConfigurationException { 
		Transformer transformer = templates.newTransformer(); 
		if (this.uriResolver != null) { 
			transformer.setURIResolver(this.uriResolver); 
		} 
		return transformer; 
	} 
 
	/** 
	 * Get the XSLT {@link Source} for the XSLT template under the {@link #setUrl configured URL}. 
	 * @return the Source object 
	 */ 
	protected Source getStylesheetSource() { 
		String url = getUrl(); 
		if (logger.isDebugEnabled()) { 
			logger.debug("Loading XSLT stylesheet from '" + url + "'"); 
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:newTransformer
    } 
     
    Transformer result = null;
     
    try { 
      result = lastTemplates.newTransformer();
    } catch(TransformerConfigurationException tce) {
      log.error(getClass().getName(), "getTransformer", tce);
      throw new IOException("newTransformer fails ( " + lastFilename + ")", tce);
    } 
     
    return result;
  } 
   
  /** Return a Templates object for the given filename */ 
  private Templates getTemplates(ResourceLoader loader, String filename,int cacheLifetimeSeconds) throws IOException {
     
    Templates result = null;
    lastFilename = null;
    try { 
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:newTransformer
					s = ERXFileUtilities.stringFromInputStream(is);
					s = templateParser.parseTemplateWithObject(s, "@@", app);
					t = fac.newTemplates(new StreamSource(new ByteArrayInputStream(s.getBytes())));
 
					if (app.isCachingEnabled()) {
						templates.put(key, t);
					} 
				} catch (IOException e1) {
					throw NSForwardException._runtimeExceptionForThrowable(e1);
				} catch (TransformerConfigurationException tce) {
					log.error("could not create template " + tce.getLocationAsString(), tce);
					log.error("  cause", tce.getCause());
					if (tce.getCause() != null && tce.getCause() instanceof org.xml.sax.SAXParseException) {
						org.xml.sax.SAXParseException e = (org.xml.sax.SAXParseException) tce.getCause();
						log.error("SAXParseException: line " + e.getLineNumber() + ", column " + e.getColumnNumber());
					} 
					log.error("this is the incorrect xsl:>>>" + s + "<<<");
					return 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:newTransformer
            assertEquals(expected, actual);
        } 
 
        @Test(expected=XsltTransformationException.class)
        public void shouldThrowExceptionIfXslTransformerCanNotBeGenerated() throws Exception {
            when(templates.newTransformer())
                    .thenThrow(new TransformerConfigurationException());
 
            //TODO: review...is it possible that too much is being done during construction? 
            new SampleXslTransform(templates).getXslTransformerPool().borrowObject();
        } 
    } 
 
    static class SampleXslTransform extends AbstractXslTransform { 
        public SampleXslTransform(Templates _transformationTemplates) {
            super(_transformationTemplates);
        } 
    } 
} 
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:newTransformer
 
    public TrAXFilter(Templates templates)  throws 
	TransformerConfigurationException 
    { 
	_templates = templates;
	_transformer = (TransformerImpl) templates.newTransformer();
        _transformerHandler = new TransformerHandlerImpl(_transformer);
    } 
     
    public Transformer getTransformer() {
        return _transformer;
    } 
 
    private void createParent() throws SAXException { 
	XMLReader parent = null;
        try { 
            SAXParserFactory pfactory = SAXParserFactory.newInstance();
            pfactory.setNamespaceAware(true);
             
            if (_transformer.isSecureProcessing()) {
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:newTransformer
 
	protected Templates templates;
 
	public Transformer getTransformer() throws TransformerConfigurationException {
 
		return templates.newTransformer();
	} 
} 
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:newTransformer
   */ 
  public TrAXFilter (Templates templates)
    throws TransformerConfigurationException 
  { 
    m_templates = templates;
    m_transformer = (TransformerImpl)templates.newTransformer();
  } 
   
  /** 
   * Return the Transformer object used for this XML filter. 
   */ 
  public TransformerImpl getTransformer() 
  { 
    return m_transformer;
  } 
   
  /** Set the parent reader. 
   * 
   * <p>This is the {@link org.xml.sax.XMLReader XMLReader} from which  
   * this filter will obtain its events and to which it will pass its  
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:newTransformer
            ); 
        Templates stylesheet = tFactory.newTemplates( stylesheetStream );
        DocumentBuilderFactory dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
        dbFactory.setNamespaceAware(true);
        DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
        Transformer transformer = stylesheet.newTransformer();
 
        Document emotion = docBuilder.parse(EmospeakTest.class.getResourceAsStream("emotion.xml"));
        javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource (emotion);
        java.io.StringWriter sw = new java.io.StringWriter();
        javax.xml.transform.stream.StreamResult streamResult = new javax.xml.transform.stream.StreamResult (sw);
        transformer.transform(domSource, streamResult);
        String maryxmlString = sw.toString();
        System.out.println("Converted to maryxml: "+maryxmlString);
    } 
     
 
} 
 
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:newTransformer
 
    public MaryData process(MaryData d)
    throws ExceptionDOMSource domSource = new DOMSource(d.getDocument());
        Transformer transformer = stylesheet.newTransformer();
 
        // Log transformation errors to client: 
        if (doWarnClient) {
            // Use custom error handler: 
            transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.Sable transformer"));
        } 
 
        // Transform DOMSource into a DOMResult 
        Document maryxmlDocument = docBuilder.newDocument();
        DOMResult domResult = new DOMResult(maryxmlDocument);
        transformer.transform(domSource, domResult);
        MaryData result = new MaryData(outputType(), d.getLocale());
        result.setDocument(maryxmlDocument);
        return result;
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 Templates Methods: