This simple transformer that can be useful for debugging any XML pipeline. It saves as a regular XML file, the SAX stream it receives. In this way we can save a snapshot of any given step of a XML pipeline.
There are other alternatives for this purpose, like these ones:
The SourceWritingTransformer. Requires you to code the desired output location in the XML stream.
Views. But there are cases where views aren't useful like a sub-pipeline that is called from other pipeline through the cocoon: protocol, and the sub-pipeline cannot be invoked directly, because the main one has set some environment like request attributes.
LogTransformer. Gives a detailed log of each received SAX event, but you don't have a usable XML file.
Profiler. It gives you a lot of features, but slows down your pipeline and increases memory usage.
Here is the component declaration:
<map:transformer name="foto" src="fcc.ima.cocoon.FotoTransformer"/>
And its a sample usage in a pipeline:
<map:generate src="my-source.xml"/> <map:transform src="my-stylesheet1.xsl"/> <map:transform type='foto' src='snapshots/snapshot1.xml'/> <map:transform src="my-stylesheet2.xsl"/> <map:transform type='foto' src='snapshots/snapshot2.xml'/> <map:serialize type='html'/>
As you can see you name the output file through the src attribute. It supports any URI scheme supported by Cocoon