/** * Create a Templates object that from the input stylesheet * Uses the org.apache.xalan.xsltc.trax.TransformerFactory. * @param source the stylesheet. * @return A Templates object. */ public Templates newTemplates(Source source) throws TransformerConfigurationException { if (_xsltcFactory == null) { createXSLTCTransformerFactory(); } if (_errorlistener != null) { _xsltcFactory.setErrorListener(_errorlistener); } if (_uriresolver != null) { _xsltcFactory.setURIResolver(_uriresolver); } _currFactory = _xsltcFactory; return _currFactory.newTemplates(source); }
/** * Create an XMLFilter that uses the given source as the * transformation instructions. Uses * org.apache.xalan.xsltc.trax.TransformerFactory. */ public XMLFilter newXMLFilter(Source src) 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); }
Templates templates = null; if (xslt != null) { templates = saxtf.newTemplates(xslt);
String href = avt.evaluate(xctxt,xt, elem); String absURI = SystemIDResolver.getAbsoluteURI(href, sysId); Templates tmpl = saxTFactory.newTemplates(new StreamSource(absURI)); TransformerHandler tHandler = saxTFactory.newTransformerHandler(tmpl); Transformer trans = tHandler.getTransformer();
public static Templates newTemplates(Source source) throws TransformerConfigurationException { return factory.newTemplates(source); } }
private TransformerHandler getTransformerHandler() throws Exception { SAXTransformerFactory tf = saxtf; if (tf == null) saxtf = tf = (SAXTransformerFactory) TransformerFactory .newInstance(); if (xsltFile == null) return tf.newTransformerHandler(); Templates tpls = xsltTpls; if (tpls == null); xsltTpls = tpls = tf.newTemplates(new StreamSource(xsltFile)); return tf.newTransformerHandler(tpls); }
/** * Compile a {@link Templates} from a given stream. The template is not added to the * pool automatically. */ public Templates compileTemplate(InputStream stream) throws SAXException { final StreamSource source = new StreamSource(stream); try { return tFactory.newTemplates(source); } catch (Exception e) { throw new SAXException("Could not compile stylesheet.", e); } }
private TransformerHandler getTransformerHandler() throws Exception { SAXTransformerFactory tf = saxtf; if (tf == null) saxtf = tf = (SAXTransformerFactory) TransformerFactory .newInstance(); if (xsltFile == null) return tf.newTransformerHandler(); Templates tpls = xsltTpls; if (tpls == null); xsltTpls = tpls = tf.newTemplates(new StreamSource(xsltFile)); return tf.newTransformerHandler(tpls); }
/** * Compile a {@link Templates} from a given system identifier. The template is not * added to the pool, a manual call to {@link #addTemplate(String, Templates)} is * required. */ public Templates compileTemplate(String systemId) throws SAXException { final StreamSource source = new StreamSource(systemId); try { return tFactory.newTemplates(source); } catch (Exception e) { throw new SAXException("Could not compile stylesheet: " + systemId, e); } }
private TransformerHandler getTransformerHandler(QidoRS main) throws Exception { SAXTransformerFactory stf = main.saxTransformer; if (stf == null) main.saxTransformer = stf = (SAXTransformerFactory) TransformerFactory .newInstance(); if (main.getXsltFile() == null) return stf.newTransformerHandler(); Templates templates = main.xsltTemplates; if (templates == null){ templates = stf.newTemplates(new StreamSource(main.xsltFile)); main.xsltTemplates = templates; } return stf.newTransformerHandler(templates); }
/** {@inheritDoc} */ public synchronized void activateOptions() { if (templates == null) { try { InputStream is = XSLTLayout.class.getResourceAsStream("default.xslt"); StreamSource ss = new StreamSource(is); templates = transformerFactory.newTemplates(ss); encoding = Charset.forName("US-ASCII"); mediaType = "text/plain"; } catch (Exception ex) { LogLog.error("Error loading default.xslt", ex); } } activated = true; }
private static TransformerHandler getTransformerHandler(WadoURI main) throws Exception { SAXTransformerFactory stf = main.saxTransformer; if (stf == null) main.saxTransformer = stf = (SAXTransformerFactory) TransformerFactory .newInstance(); if (main.getXsltFile() == null) return stf.newTransformerHandler(); Templates templates = main.xsltTemplates; if (templates == null){ templates = stf.newTemplates(new StreamSource(main.xsltFile)); main.xsltTemplates = templates; } return stf.newTransformerHandler(templates); }
/** {@inheritDoc} */ public synchronized void activateOptions() { if (templates == null) { try { InputStream is = XSLTLayout.class.getResourceAsStream("default.xslt"); StreamSource ss = new StreamSource(is); templates = transformerFactory.newTemplates(ss); encoding = Charset.forName("US-ASCII"); mediaType = "text/plain"; } catch (Exception ex) { LogLog.error("Error loading default.xslt", ex); } } activated = true; }
/** {@inheritDoc} */ public synchronized void activateOptions() { if (templates == null) { try { InputStream is = XSLTLayout.class.getResourceAsStream("default.xslt"); StreamSource ss = new StreamSource(is); templates = transformerFactory.newTemplates(ss); encoding = Charset.forName("US-ASCII"); mediaType = "text/plain"; } catch (Exception ex) { LogLog.error("Error loading default.xslt", ex); } } activated = true; }
/** {@inheritDoc} */ public synchronized void activateOptions() { if (templates == null) { try { InputStream is = XSLTLayout.class.getResourceAsStream("default.xslt"); StreamSource ss = new StreamSource(is); templates = transformerFactory.newTemplates(ss); encoding = Charset.forName("US-ASCII"); mediaType = "text/plain"; } catch (Exception ex) { LogLog.error("Error loading default.xslt", ex); } } activated = true; }
private void init(final AbstractPipelineInput input) { try { final File styleFile = new File(input.getAttribute(ANT_INVOKER_EXT_PARAM_STYLE)); templates = transformerFactory.newTemplates(new StreamSource(styleFile)); serializer = transformerFactory.newTransformer(); } catch (TransformerConfigurationException e) { throw new RuntimeException(e); } if (fileInfoFilter == null) { fileInfoFilter = fileInfo -> fileInfo.format != null && fileInfo.format.equals(ATTR_FORMAT_VALUE_DITAMAP); } }
protected Templates createTemplates(URL urlStream) { try { if (urlStream == null) { return null; } Reader r = new BufferedReader( new InputStreamReader(urlStream.openStream(), StandardCharsets.UTF_8)); Source source = new StreamSource(r); source.setSystemId(urlStream.toExternalForm()); if (factory == null) { factory = (SAXTransformerFactory)TransformerFactory.newInstance(); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, secureProcessing); if (uriResolver != null) { factory.setURIResolver(uriResolver); } } return factory.newTemplates(source); } catch (Exception ex) { LOG.warning("No template can be created : " + ex.getMessage()); } return null; }
@SuppressWarnings("resource") private Templates create(final String inputXsltScript, final SAXTransformerFactory transformerFactory) throws TransformerConfigurationException, IOException { if (inputXsltScript == null) { return null; } try (final InputStream stream = this.connector.execute(inputXsltScript)) { if (logger.isLoggable(ILevel.DEBUG)) { logger.log(ILevel.DEBUG, inputXsltScript); } return transformerFactory.newTemplates(new StreamSource(new NoneClosingInputStream(stream))); } } }
@SuppressWarnings("resource") private Templates create(final String inputXsltScript, final SAXTransformerFactory transformerFactory) throws TransformerConfigurationException, IOException { if (inputXsltScript == null) { return null; } try (final InputStream stream = this.connector.execute(inputXsltScript)) { if (logger.isLoggable(ILevel.DEBUG)) { logger.log(ILevel.DEBUG, inputXsltScript); } return transformerFactory.newTemplates(new StreamSource(new NoneClosingInputStream(stream))); } } }
/** * Create an XMLFilter that uses the given source as the * transformation instructions. Uses * com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactory. */ public XMLFilter newXMLFilter(Source src) 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); }