Hi Simone,

Hi Simone,

Just to get things straight. That unit test I wrote worked just fine even 
though I set .withEmptyConfiguration()

I had to make slight modification to the test you proposed but it failed where 
you probably expected it to work. So setting the configuration did NOT work.  
That's what I mean with uniformity of setting component parameters.  
setConfiguration(params) seems to be intended for the use case where the 
pipelinebuilder installs components by fetching beans from applicationcontext 
(using empty constructors) and it's up to the component author to ensure that 
parameters are properly converted inside that method to e.g. URL's

I will need more time to really analyze all components and if they are 
following similar approach of working (and also the unit tests).   But I expect 
there might be some rework and even more importantly... someone should decide 
and document the proper strategy of how components should be initialized and 
configured.

I will catch you in 3 weeks again after my holidays.
Robby


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


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

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

        newCachingPipeline()
            .setStarter(new XMLGenerator("<x></x>"))
            .addComponent(new 
XSLTTransformer(this.getClass().getResource("/test.xslt")))
            .setFinisher(new XMLSerializer())
            .setConfiguration(transformerParams)
            .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());
    }


-----Original Message-----
From: simone.trip...@gmail.com [mailto:simone.trip...@gmail.com] On Behalf Of 
Simone Tripodi
Sent: Thursday, July 07, 2011 5:27 PM
To: dev@cocoon.apache.org
Subject: Re: uniformity of passing parameters to components Cocoon 3

Hi Robby,
I'm worried about the {{withEmptyConfiguration()}} call, it should
reset the {{transformerParams.put("myParam", "value-of-myparam");}}
invocation; would you mind to modify and test your code as shown
below?
Many thanks in advance, have a nice day!
Simo

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


        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(new
XSLTTransformer(this.getClass().getResource("/test.xslt"),
attributes))
            .setFinisher(new XMLSerializer())
            .setConfiguration(transformerParams)
            .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());
    }

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Thu, Jul 7, 2011 at 2:04 PM, Robby Pelssers <robby.pelss...@nxp.com> wrote:
> 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