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

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

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

Transformer.setURIResolver介绍

[英]Set an object that will be used to resolve URIs used in document().

If the resolver argument is null, the URIResolver value will be cleared and the transformer will no longer have a resolver.
[中]设置将用于解析文档()中使用的URI的对象。
如果解析器参数为null,则URIResolver值将被清除,并且转换器将不再具有解析器。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create the {@link Transformer} instance used to prefer the XSLT transformation.
 * <p>The default implementation simply calls {@link Templates#newTransformer()}, and
 * configures the {@link Transformer} with the custom {@link URIResolver} if specified.
 * @param templates the XSLT Templates instance to create a Transformer for
 * @return the Transformer object
 * @throws TransformerConfigurationException in case of creation failure
 */
protected Transformer createTransformer(Templates templates) throws TransformerConfigurationException {
  Transformer transformer = templates.newTransformer();
  if (this.uriResolver != null) {
    transformer.setURIResolver(this.uriResolver);
  }
  return transformer;
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * Create the {@link Transformer} instance used to prefer the XSLT transformation.
 * <p>The default implementation simply calls {@link Templates#newTransformer()}, and
 * configures the {@link Transformer} with the custom {@link URIResolver} if specified.
 * @param templates the XSLT Templates instance to create a Transformer for
 * @return the Transformer object
 * @throws TransformerConfigurationException in case of creation failure
 */
protected Transformer createTransformer(Templates templates) throws TransformerConfigurationException {
  Transformer transformer = templates.newTransformer();
  if (this.uriResolver != null) {
    transformer.setURIResolver(this.uriResolver);
  }
  return transformer;
}

代码示例来源:origin: xalan/xalan

/**
 * javax.xml.transform.sax.TransformerFactory implementation.
 * Process the Source into a Templates object, which is a a compiled
 * representation of the source. Note that this method should not be
 * used with XSLTC, as the time-consuming compilation is done for each
 * and every transformation.
 *
 * @return A Templates object that can be used to create Transformers.
 * @throws TransformerConfigurationException
 */
public Transformer newTransformer(Source source) throws
TransformerConfigurationException 
{
final Templates templates = newTemplates(source);
final Transformer transformer = templates.newTransformer();
if (_uriResolver != null) {
  transformer.setURIResolver(_uriResolver);
}
return(transformer);
}

代码示例来源:origin: xalan/xalan

/**
 * javax.xml.transform.sax.SAXTransformerFactory implementation.
 * Get a TransformerHandler object that can process SAX ContentHandler
 * events into a Result. This method will return a pure copy transformer.
 *
 * @return A TransformerHandler object that can handle SAX events
 * @throws TransformerConfigurationException
 */
public TransformerHandler newTransformerHandler() 
throws TransformerConfigurationException 
{
final Transformer transformer = newTransformer();
if (_uriResolver != null) {
  transformer.setURIResolver(_uriResolver);
}
return new TransformerHandlerImpl((TransformerImpl) transformer);
}

代码示例来源:origin: xalan/xalan

/**
 * javax.xml.transform.sax.SAXTransformerFactory implementation.
 * Get a TransformerHandler object that can process SAX ContentHandler
 * events into a Result, based on the transformation instructions
 * specified by the argument.
 *
 * @param src The source of the transformation instructions.
 * @return A TransformerHandler object that can handle SAX events
 * @throws TransformerConfigurationException
 */
public TransformerHandler newTransformerHandler(Source src) 
throws TransformerConfigurationException 
{ 
final Transformer transformer = newTransformer(src);
if (_uriResolver != null) {
  transformer.setURIResolver(_uriResolver);
}
return new TransformerHandlerImpl((TransformerImpl) transformer);
}

代码示例来源:origin: org.apache.ant/ant

transformer.setURIResolver(uriResolver);

代码示例来源:origin: robovm/robovm

transformer.setURIResolver(m_uriResolver);
return transformer;

代码示例来源:origin: xalan/xalan

transformer.setURIResolver(m_uriResolver);
return transformer;

代码示例来源:origin: xalan/xalan

transformer.setURIResolver(uriResolver);

代码示例来源:origin: jamesagnew/hapi-fhir

public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws FileNotFoundException, TransformerException  {
 TransformerFactory f = TransformerFactory.newInstance();
 StreamSource xsrc = new StreamSource(new FileInputStream(xslt));
 f.setURIResolver(new MyURIResolver(xsltDir, alt));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new MyURIResolver(xsltDir, alt));
 StreamSource src = new StreamSource(new FileInputStream(source));
 StreamResult res = new StreamResult(new FileOutputStream(dest));
 t.transform(src, res);
 
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws Exception {
 TransformerFactory f = TransformerFactory.newInstance();
 StreamSource xsrc = new StreamSource(new FileInputStream(xslt));
 f.setURIResolver(new MyURIResolver(xsltDir, alt));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new MyURIResolver(xsltDir, alt));
 StreamSource src = new StreamSource(new FileInputStream(source));
 StreamResult res = new StreamResult(new FileOutputStream(dest));
 t.transform(src, res);
 
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static void transform(String xsltDir, String source, String xslt, String dest, URIResolver alt) throws FileNotFoundException, TransformerException  {
 TransformerFactory f = TransformerFactory.newInstance();
 StreamSource xsrc = new StreamSource(new FileInputStream(xslt));
 f.setURIResolver(new MyURIResolver(xsltDir, alt));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new MyURIResolver(xsltDir, alt));
 StreamSource src = new StreamSource(new FileInputStream(source));
 StreamResult res = new StreamResult(new FileOutputStream(dest));
 t.transform(src, res);
 
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static byte[] transform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException  {
 TransformerFactory f = TransformerFactory.newInstance();
 f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
 StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt));
 f.setURIResolver(new ZipURIResolver(files));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new ZipURIResolver(files));
 StreamSource src = new StreamSource(new ByteArrayInputStream(source));
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 StreamResult res = new StreamResult(out);
 t.transform(src, res);
 return out.toByteArray();    
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static byte[] transform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws Exception {
 TransformerFactory f = TransformerFactory.newInstance();
 f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
 StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt));
 f.setURIResolver(new ZipURIResolver(files));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new ZipURIResolver(files));
 StreamSource src = new StreamSource(new ByteArrayInputStream(source));
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 StreamResult res = new StreamResult(out);
 t.transform(src, res);
 return out.toByteArray();    
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static byte[] transform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException  {
 TransformerFactory f = TransformerFactory.newInstance();
 f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
 StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt));
 f.setURIResolver(new ZipURIResolver(files));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new ZipURIResolver(files));
 StreamSource src = new StreamSource(new ByteArrayInputStream(source));
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 StreamResult res = new StreamResult(out);
 t.transform(src, res);
 return out.toByteArray();    
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static byte[] saxonTransform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws TransformerException  {
 TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl();
 f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
 StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt));
 f.setURIResolver(new ZipURIResolver(files));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new ZipURIResolver(files));
 StreamSource src = new StreamSource(new ByteArrayInputStream(source));
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 StreamResult res = new StreamResult(out);
 t.transform(src, res);
 return out.toByteArray();    
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static byte[] saxonTransform(Map<String, byte[]> files, byte[] source, byte[] xslt) throws Exception {
 TransformerFactory f = new net.sf.saxon.TransformerFactoryImpl();
 f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
 StreamSource xsrc = new StreamSource(new ByteArrayInputStream(xslt));
 f.setURIResolver(new ZipURIResolver(files));
 Transformer t = f.newTransformer(xsrc);
 t.setURIResolver(new ZipURIResolver(files));
 StreamSource src = new StreamSource(new ByteArrayInputStream(source));
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 StreamResult res = new StreamResult(out);
 t.transform(src, res);
 return out.toByteArray();    
}

代码示例来源:origin: jamesagnew/hapi-fhir

public static void saxonTransform(String xsltDir, String source, String xslt, String dest, URIResolver alt, Map<String, String> params) throws FileNotFoundException, TransformerException  {
 TransformerFactoryImpl f = new net.sf.saxon.TransformerFactoryImpl();
 f.setAttribute("http://saxon.sf.net/feature/version-warning", Boolean.FALSE);
 StreamSource xsrc = new StreamSource(new FileInputStream(xslt));
 f.setURIResolver(new MyURIResolver(xsltDir, alt));
 Transformer t = f.newTransformer(xsrc);
  if (params != null) {
    for (Map.Entry<String, String> entry : params.entrySet()) {
     t.setParameter(entry.getKey(), entry.getValue());
    }
 }
 
 t.setURIResolver(new MyURIResolver(xsltDir, alt));
 StreamSource src = new StreamSource(new FileInputStream(source));
 StreamResult res = new StreamResult(new FileOutputStream(dest));
 t.transform(src, res);    
}

代码示例来源:origin: apache/cxf

public Transformer newTransformer() throws TransformerConfigurationException {
  Transformer tr = templates.newTransformer();
  tr.setURIResolver(resolver);
  for (Map.Entry<String, Object> entry : transformParameters.entrySet()) {
    tr.setParameter(entry.getKey(), entry.getValue());
  }
  for (Map.Entry<String, String> entry : outProps.entrySet()) {
    tr.setOutputProperty(entry.getKey(), entry.getValue());
  }
  return tr;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public Transformer newTransformer() throws TransformerConfigurationException {
  Transformer tr = templates.newTransformer();
  tr.setURIResolver(resolver);
  for (Map.Entry<String, Object> entry : transformParameters.entrySet()) {
    tr.setParameter(entry.getKey(), entry.getValue());
  }
  for (Map.Entry<String, String> entry : outProps.entrySet()) {
    tr.setOutputProperty(entry.getKey(), entry.getValue());
  }
  return tr;
}

相关文章