javax.xml.transform.Transformer.getURIResolver()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中javax.xml.transform.Transformer.getURIResolver()方法的一些代码示例,展示了Transformer.getURIResolver()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transformer.getURIResolver()方法的具体详情如下:
包路径:javax.xml.transform.Transformer
类名称:Transformer
方法名:getURIResolver

Transformer.getURIResolver介绍

[英]Get an object that will be used to resolve URIs used in document().
[中]获取一个对象,该对象将用于解析文档()中使用的URI。

代码示例

代码示例来源:origin: apache/servicemix-bundles

@Override
public javax.xml.transform.URIResolver getURIResolver() {
  try {
    materialize();
    return m_realTransformer.getURIResolver();
  } catch (TransformerException e) {
    // will be caught later
  }
  return null;
}

代码示例来源:origin: org.n52.metadata/smarteditor-api

public Transformer getTransformer(String xsltResource) throws TransformerConfigurationException {
  Templates templates = getTemplates(xsltResource);
  if (templates == null) {
    return null;
  }
  // the URIResolver of the factory is lost by templates, make sure to set
  // it so the paths are resolved correctly
  Transformer transformer = templates.newTransformer();
  if (transformer.getURIResolver() == null) {
    transformer.setURIResolver(new ClasspathResolver());
  }
  return transformer;
}

代码示例来源:origin: org.ikasan/ikasan-filetransfer-common

URIResolver resolver = this.transformer.getURIResolver();
if ((resolver != null) && !(resolver instanceof DefaultURIResolver))
  (DefaultURIResolver)this.transformer.getURIResolver();

代码示例来源:origin: org.ikasan/ikasan-common

URIResolver resolver = this.transformer.getURIResolver();
if ((resolver != null) && !(resolver instanceof DefaultURIResolver))
  (DefaultURIResolver)this.transformer.getURIResolver();

代码示例来源:origin: org.pageseeder.epub/pso-epub-core

/**
 * Utility function to transforms the specified XML source and returns the results as XML.
 *
 * Problems will be reported in the logs, the output will simply produce results as a comment.
 *
 * @param source     The Source XML data.
 * @param result     The Result data.
 * @param templates  The XSLT templates to use.
 * @param parameters Parameters to transmit to the transformer for use by the stylesheet (optional)
 *
 * @throws BuildException For XSLT Transformation errors or XSLT configuration errors
 */
public static void transform(Source source, Result result, Templates templates, Map<String, String> parameters) {
 try {
  // Create a transformer from the templates
  Transformer transformer = templates.newTransformer();
  URIResolver resolver = transformer.getURIResolver();
  transformer.setURIResolver(new LocalResolver(resolver));
  // Transmit the properties to the transformer
  if (parameters != null) {
   for (Entry<String, String> e : parameters.entrySet()) {
    transformer.setParameter(e.getKey(), e.getValue());
   }
  }
  // Transform
  transformer.transform(source, result);
 } catch (TransformerException ex) {
  throw new EPubException("Unable to transform ", ex);
 }
}

代码示例来源:origin: apache/ofbiz-framework

/** Transform an xsl-fo StreamSource to the specified output format.
 * @param src The xsl-fo StreamSource instance
 * @param stylesheet Optional stylesheet StreamSource instance
 * @param fop
 */
public static void transform(StreamSource src, StreamSource stylesheet, Fop fop) throws FOPException {
  Result res = new SAXResult(fop.getDefaultHandler());
  try {
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer;
    if (stylesheet == null) {
      transformer = factory.newTransformer();
    } else {
      transformer = factory.newTransformer(stylesheet);
    }
    transformer.setURIResolver(new LocalResolver(transformer.getURIResolver()));
    transformer.transform(src, res);
  } catch (Exception e) {
    throw new FOPException(e);
  }
}

相关文章