This is a more advanced sample of using the SVG Serializer.
 |  |  |
 |
<map:serializers>
<map:serializer>
<map:serializer name="svg2jpeg" mime-type="image/jpeg"
src="org.apache.cocoon.serialization.SVGSerializer">
<parameter name="transcoder"
value="org.apache.batik.transcoder.image.JPEGTranscoder"/>
<parameter name="background_color" type="color" value="#00FF00"/>
</map:serializer>
<map:serializers>
...
<map:pipeline>
<map:match pattern="sample.jpeg">
<map:generate type="file" src="sample.svg"/>
<map:serialize type="svg2jpeg"/>
</map:match>
</map:pipeline>
|  |
 |  |  |
In this example another parameter is given to the serializer,
background_color
. This parameter is passed to the
transcoder. The type
argument specifies the type of
data to convert the value
to. In this example the
string "#00FF00" is converted to a Color
object, which
is passed to the transcoder as the background colour to
use.
For a list of the parameters available for each transcoder, refer to
the Batik API docs.
For this to work reliably with any transcoder, some magic must be
done. First, the parameter name is transformed to upper-case and then "KEY_" is
prepended. This is to match the internal naming scheme of the hints
in the Batik Transcoder
interfaces. This name is then
looked up via Reflection to ensure it is a valid parameter on the
specified transcoder. Then the value is converted to the type
specified in the type
attribute (currently supported
types are string, float, integer, boolean and color) and passed to
the transcoder.