本文整理汇总了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());
}
}