Hi all,

I noticed that the XSLTTransformer class has a separate setParameters method. 
So using pipeline.setup(outputstream, params) will not work.  I can understand 
the reasoning behind this, but my initial understanding was that you should use 
 pipelinecomponent.setup(params) for this.     But this seems to be overridden 
when you invoke pipeline.setup(outputstream, params).

Can someone explain a bit high level what the proper way of working is?



    public void testPipelineWithCompiledXSLT() throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put("translet-name", "CompiledXslt");
        attributes.put("package-name", "org.apache.cocoon.sax");


        Map<String, Object> transformerParams = new HashMap<String, Object>();
        transformerParams.put("myParam", "value-of-myparam");

        XSLTTransformer transformer = new 
XSLTTransformer(this.getClass().getResource("/test.xslt"), attributes);
        transformer.setParameters(transformerParams);

        newCachingPipeline()
            .setStarter(new XMLGenerator("<x></x>"))
            .addComponent(transformer)
            .setFinisher(new XMLSerializer())
            .withEmptyConfiguration()
            .setup(baos)
            .execute();

        Diff diff = new Diff("<?xml version=\"1.0\" 
encoding=\"UTF-8\"?><p>value-of-myparam</p>", new String(baos.toByteArray()));
        assertTrue("XSL transformation didn't work as expected " + diff, 
diff.identical());
    }

Reply via email to