use of org.apache.camel.builder.xml.XsltUriResolver in project camel by apache.
the class SaxonUriResolverTest method test.
@Test
public void test() throws Exception {
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
Source xsl = fromClasspath(XSL_PATH);
xsl.setSystemId("classpath:/" + XSL_PATH);
Source xml = fromString(XML_DATA);
TransformerFactory factory = new TransformerFactoryImpl();
Transformer transformer = factory.newTransformer(xsl);
transformer.setURIResolver(new XsltUriResolver(context(), XSL_PATH));
transformer.transform(xml, result);
Assert.assertEquals(XML_RESP, writer.toString());
}
use of org.apache.camel.builder.xml.XsltUriResolver in project camel by apache.
the class XsltAggregationStrategy method initialize.
protected void initialize(CamelContext context) throws Exception {
// set the default property name if not set
this.propertyName = ObjectHelper.isNotEmpty(propertyName) ? propertyName : DEFAULT_PROPERTY_NAME;
// initialize the XsltBuilder
this.xslt = context.getInjector().newInstance(XsltBuilder.class);
if (transformerFactoryClass != null) {
Class<?> factoryClass = context.getClassResolver().resolveMandatoryClass(transformerFactoryClass, XsltAggregationStrategy.class.getClassLoader());
TransformerFactory factory = (TransformerFactory) context.getInjector().newInstance(factoryClass);
xslt.getConverter().setTransformerFactory(factory);
}
if (uriResolver == null) {
uriResolver = new XsltUriResolver(context, xslFile);
}
xslt.setUriResolver(uriResolver);
xslt.setFailOnNullBody(true);
xslt.transformerCacheSize(0);
xslt.setAllowStAX(true);
configureOutput(xslt, output.name());
loadResource(xslFile);
}
Aggregations