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 <[email protected]> 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());
>
> }