Search in sources :

Example 1 with TransformerFactoryImpl

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);
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) TransformerFactoryImpl(net.sf.saxon.TransformerFactoryImpl) Templates(javax.xml.transform.Templates) Test(org.junit.Test)

Example 2 with TransformerFactoryImpl

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());
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) TransformerFactoryImpl(net.sf.saxon.TransformerFactoryImpl) Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) XsltUriResolver(org.apache.camel.builder.xml.XsltUriResolver) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) Test(org.junit.Test)

Example 3 with TransformerFactoryImpl

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);
}
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)

Example 4 with TransformerFactoryImpl

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);
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) TransformerFactoryImpl(net.sf.saxon.TransformerFactoryImpl) Templates(javax.xml.transform.Templates)

Example 5 with TransformerFactoryImpl

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;
}
Also used : TransformerFactoryImpl(net.sf.saxon.TransformerFactoryImpl)

Aggregations

TransformerFactoryImpl (net.sf.saxon.TransformerFactoryImpl)6 TransformerFactory (javax.xml.transform.TransformerFactory)4 Templates (javax.xml.transform.Templates)3 Test (org.junit.Test)2 StringWriter (java.io.StringWriter)1 Source (javax.xml.transform.Source)1 Transformer (javax.xml.transform.Transformer)1 StreamResult (javax.xml.transform.stream.StreamResult)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Configuration (net.sf.saxon.Configuration)1 XsltUriResolver (org.apache.camel.builder.xml.XsltUriResolver)1 ClassPathURIResolver (org.apache.camel.component.schematron.processor.ClassPathURIResolver)1 BeforeClass (org.junit.BeforeClass)1