Search in sources :

Example 1 with ClassPathURIResolver

use of org.apache.camel.component.schematron.processor.ClassPathURIResolver in project camel by apache.

the class SchematronEndpoint method createTransformerFactory.

private void createTransformerFactory() throws ClassNotFoundException {
    // provide the class loader of this component to work in OSGi environments
    Class<TransformerFactory> factoryClass = getCamelContext().getClassResolver().resolveMandatoryClass(SAXON_TRANSFORMER_FACTORY_CLASS_NAME, TransformerFactory.class, SchematronComponent.class.getClassLoader());
    LOG.debug("Using TransformerFactoryClass {}", factoryClass);
    transformerFactory = getCamelContext().getInjector().newInstance(factoryClass);
    transformerFactory.setURIResolver(new ClassPathURIResolver(Constants.SCHEMATRON_TEMPLATES_ROOT_DIR, this.uriResolver));
    transformerFactory.setAttribute(LINE_NUMBERING, true);
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) ClassPathURIResolver(org.apache.camel.component.schematron.processor.ClassPathURIResolver)

Example 2 with ClassPathURIResolver

use of org.apache.camel.component.schematron.processor.ClassPathURIResolver 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);
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) TransformerFactoryImpl(net.sf.saxon.TransformerFactoryImpl) Templates(javax.xml.transform.Templates) ClassPathURIResolver(org.apache.camel.component.schematron.processor.ClassPathURIResolver) BeforeClass(org.junit.BeforeClass)

Aggregations

TransformerFactory (javax.xml.transform.TransformerFactory)2 ClassPathURIResolver (org.apache.camel.component.schematron.processor.ClassPathURIResolver)2 Templates (javax.xml.transform.Templates)1 TransformerFactoryImpl (net.sf.saxon.TransformerFactoryImpl)1 BeforeClass (org.junit.BeforeClass)1