當前位置: 首頁>>代碼示例>>Java>>正文


Java SAXTransformerFactory.newTemplates方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:apache,項目名稱:syncope,代碼行數:21,代碼來源:XSLTTransformer.java

示例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)));
  }
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:15,代碼來源:RegistableConvertingXmlPersisterFactory.java

示例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;
    }
 
開發者ID:evlist,項目名稱:orbeon-forms,代碼行數:15,代碼來源:TransformerUtils.java

示例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());
	}
}
 
開發者ID:OpenCCG,項目名稱:openccg,代碼行數:15,代碼來源:CCGBankExtract.java


注:本文中的javax.xml.transform.sax.SAXTransformerFactory.newTemplates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。