本文整理匯總了Java中javax.xml.transform.sax.SAXTransformerFactory.newTemplates方法的典型用法代碼示例。如果您正苦於以下問題:Java SAXTransformerFactory.newTemplates方法的具體用法?Java SAXTransformerFactory.newTemplates怎麽用?Java SAXTransformerFactory.newTemplates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.transform.sax.SAXTransformerFactory
的用法示例。
在下文中一共展示了SAXTransformerFactory.newTemplates方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: load
import javax.xml.transform.sax.SAXTransformerFactory; //導入方法依賴的package包/類
private void load(final Source source, final String localCacheKey, final Map<String, Object> attributes) {
LOG.debug("{} local cache miss: {}", getClass().getSimpleName(), localCacheKey);
// XSLT has to be parsed
final SAXTransformerFactory transformerFactory;
if (attributes == null || attributes.isEmpty()) {
transformerFactory = TRAX_FACTORY;
} else {
transformerFactory = createNewSAXTransformerFactory();
attributes.entrySet().forEach(attribute -> {
transformerFactory.setAttribute(attribute.getKey(), attribute.getValue());
});
}
try {
this.templates = transformerFactory.newTemplates(source);
} catch (TransformerConfigurationException e) {
throw new SetupException("Impossible to read XSLT from '" + source + "', see nested exception", e);
}
}
示例2: create
import javax.xml.transform.sax.SAXTransformerFactory; //導入方法依賴的package包/類
@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)));
}
}
示例3: getTemplates
import javax.xml.transform.sax.SAXTransformerFactory; //導入方法依賴的package包/類
public static Templates getTemplates(Source source, String clazz, Map attributes, Configuration configuration, ErrorListener errorListener, URIResolver uriResolver)
throws TransformerConfigurationException {
final SAXTransformerFactory factory = (attributes != null) ? getFactory(clazz, attributes, configuration) : getFactory(clazz);
factory.setErrorListener(errorListener);
factory.setURIResolver(uriResolver);
final Templates templates = factory.newTemplates(source);
// These should only be used during stylesheet compilation. It is dangerous to keep them around when the
// Templates object is cached especially the URI Resolver which may reference PipelineContext objects.
// factory.setErrorListener(null);// This causes issues with Xalan
factory.setURIResolver(null);
return templates;
}
示例4: loadTemplates
import javax.xml.transform.sax.SAXTransformerFactory; //導入方法依賴的package包/類
Templates loadTemplates(String resourceName) throws BuildException {
try {
// XXX nb: no xsltc option this way
//TransformerFactory tf = XSLTProcessor.newTransformerFactory();
SAXTransformerFactory tf = (SAXTransformerFactory)TransformerFactory.newInstance();
return tf.newTemplates(new StreamSource(new BufferedInputStream(
getResource(resourceName))));
}
catch(TransformerConfigurationException e) {
throw new BuildException("Problem loading template "
+ resourceName + ": " + e.getMessage(), e, getLocation());
}
}