use of net.sf.saxon.TransformerFactoryImpl in project camel by apache.
the class TemplatesFactoryTest method testInstantiateAnInstanceOfTemplates.
@Test
public void testInstantiateAnInstanceOfTemplates() throws Exception {
TemplatesFactory fac = TemplatesFactory.newInstance();
TransformerFactory factory = new TransformerFactoryImpl();
factory.setURIResolver(new ClassPathURIResolver(Constants.SCHEMATRON_TEMPLATES_ROOT_DIR, null));
Templates templates = fac.getTemplates(ClassLoader.getSystemResourceAsStream(rules), factory);
Assert.assertNotNull(templates);
}
use of net.sf.saxon.TransformerFactoryImpl 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 net.sf.saxon.TransformerFactoryImpl 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 net.sf.saxon.TransformerFactoryImpl 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);
}
use of net.sf.saxon.TransformerFactoryImpl in project intellij-community by JetBrains.
the class Saxon9Support method createTransformerFactory.
public static TransformerFactory createTransformerFactory() {
final TransformerFactoryImpl factory = new TransformerFactoryImpl();
factory.setAttribute(FeatureKeys.TRACE_LISTENER, new Saxon9TraceListener());
try {
factory.setAttribute(FeatureKeys.OPTIMIZATION_LEVEL, "0");
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
return factory;
}
Aggregations