Working with Cocoon to do XML processing is really pleasant. The concept of pipelines is very well implemented. But sometimes we want just a bit more information about how the XML looks during the transformation process. We can use the label/view mechanism of Cocoon. This involves creating a view and assigning it to a step in the transformation process via the label attribute. In the URL we can add ?cocoon-view=view
and we get the XML of that step.
But sometimes this is not enough for me, or it doesn't quite give me the output of a particular step. That is why we can use the TeeTransformer
. The transformer simply places the XML of the transformation so far in a file. This is very easy because we can simply open the file in our favorite XML editor to analyze the result
To use the TeeTransformer
we must first add it in the sitemap.xmap
in the map:transfomers
section:
<map:transformer logger="sitemap.transformer.tee" name="tee" src="org.apache.cocoon.transformation.TeeTransformer"/>
Now we can use the transformer in a pipeline. For example to get the XML output and save it to a file with the name debug.xml
in c:\temp
we add the following line to a pipeline:
<map:transformer type="tee" src="file:///c:/temp/debug.xml"/>