use of javax.xml.transform.Templates in project bnd by bndtools.
the class Transform method transform.
public static void transform(TransformerFactory transformerFactory, URL xslt, InputStream in, OutputStream out) throws Exception {
if (xslt == null)
throw new IllegalArgumentException("No source template specified");
Templates templates = cache.get(xslt.toURI());
if (templates == null) {
try (InputStream xsltIn = xslt.openStream()) {
templates = transformerFactory.newTemplates(new StreamSource(xsltIn));
cache.put(xslt.toURI(), templates);
}
}
Result xmlResult = new StreamResult(out);
Source xmlSource = new StreamSource(in);
Transformer t = templates.newTransformer();
t.transform(xmlSource, xmlResult);
out.flush();
}
use of javax.xml.transform.Templates in project mondrian by pentaho.
the class DomBuilder method debug.
public static void debug(Document doc) {
try {
TransformerFactory tf = TransformerFactory.newInstance();
StringReader input = new StringReader(PRETTY_PRINTER);
Templates templates = tf.newTemplates(new StreamSource(input));
OutputStream result = new ByteArrayOutputStream();
templates.newTransformer().transform(new DOMSource(doc), new StreamResult(result));
LOGGER.debug(result.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
use of javax.xml.transform.Templates in project cxf by apache.
the class XSLTJaxbProvider method getInTemplates.
protected Templates getInTemplates(Annotation[] anns, MediaType mt) {
Templates t = createTemplatesFromContext();
if (t != null) {
return t;
}
t = inTemplates != null ? inTemplates : inMediaTemplates != null ? inMediaTemplates.get(mt.getType() + "/" + mt.getSubtype()) : null;
if (t == null) {
t = getAnnotationTemplates(anns);
}
return t;
}
use of javax.xml.transform.Templates in project camel by apache.
the class SchematronProducerTest method setUP.
@BeforeClass
public static void setUP() {
SchematronEndpoint endpoint = new SchematronEndpoint();
TransformerFactory fac = new TransformerFactoryImpl();
fac.setURIResolver(new ClassPathURIResolver(Constants.SCHEMATRON_TEMPLATES_ROOT_DIR, endpoint.getUriResolver()));
Templates templates = TemplatesFactory.newInstance().getTemplates(ClassLoader.getSystemResourceAsStream("sch/schematron-1.sch"), fac);
endpoint.setRules(templates);
producer = new SchematronProducer(endpoint);
}
use of javax.xml.transform.Templates in project camel by apache.
the class SchematronProcessorTest method getProcessor.
/**
* Returns schematron processor
*
* @param schematron
* @param clientResolver
* @return
*/
private SchematronProcessor getProcessor(final String schematron, final URIResolver clientResolver) {
TransformerFactory factory = new TransformerFactoryImpl();
factory.setURIResolver(new ClassPathURIResolver(Constants.SCHEMATRON_TEMPLATES_ROOT_DIR, clientResolver));
Templates rules = TemplatesFactory.newInstance().getTemplates(ClassLoader.getSystemResourceAsStream(schematron), factory);
return SchematronProcessorFactory.newScehamtronEngine(rules);
}
Aggregations