Using FOP with Cooktop

Earlier versions of Cooktop included FOP for rendering PDF documents, since version 2.2 this changed. The development of FOP continues and the general mechanisms for including this JAVA package in Cooktop have been provided but unfortunately I could not figure out how to get FOP running in Cooktop. Thus, a short introduction how you can change the configuration files of Cooktop to include FOP (I am sure there are more elegant ways but this is working). I tested this with Cooktop 2.5 and FOP 0.20.5RC2 which can be obtained via www.xmlcooktop.com and xml.apache.org/fop. The german version of this guide is available via this page.

The instalation directory includes a subdir called xslt/fop. We need to copy the build and lib dir from the FOP distribution here. Now the required JAR archives are in place.

The next step is to register the archives in Cooktop. You can edit the configuration XML file directly in Cooktop by clicking "Options/System XML/Manage XSLT engines". Navigate to the "Apache FOP section" which should like the following:


<XSLT
name="Apache FOP"
type="external"
exec="&quot;%CONFIG%\xslt\fop\fop.bat&quot; &quot;file:///!xml!&quot; &quot;file:///!xsl!&quot; &quot;!res!&quot; &quot;!res-no-ext!.pdf&quot;"
path="%CONFIG%\xslt\fop"
supported_func="system-property"
http-support="no"
installed="no"
code-url="http://xml.apache.org/fop/">
<ENVIRONMENT>
<ITEM
name="CLASSPATH"
value="%CONFIG%\xslt\fop\fop.jar;%CONFIG%\xslt\fop\xerces.jar;%CONFIG%\xslt\fop\w3c.jar;%CONFIG%\xslt\fop\xalan.jar" />
</ENVIRONMENT>
</XSLT>

This section declared the call for the batch file Fop.bat and sets the parameters. the "installed" has to be set to yes. There seem to be a few problems with the file protocol and the the local environment variables. I decided to shift setting the environment variables to the batch file.


name="Apache FOP"
type="external"
exec="&quot;%CONFIG%\xslt\fop\fop.bat&quot; &quot;!xml!&quot; &quot;!xsl!&quot; &quot;!res!&quot; &quot;!res-no-ext!.pdf&quot;"
path="%CONFIG%\xslt\fop"
supported_func="system-property"
http-support="no"
installed="yes"
code-url="http://xml.apache.org/fop/">
<!-- <ENVIRONMENT>
<ITEM
name="CLASSPATH"
value="%CONFIG%\xslt\fop\build\fop.jar;
%CONFIG%\xslt\fop\lib\xml-apis.jar;
%CONFIG%\xslt\fop\lib\xercesImpl-2.2.1.jar;
%CONFIG%\xslt\fop\lib\xalan-2.4.1.jar;
%CONFIG%\xslt\fop\lib\batik.jar;
%CONFIG%\xslt\fop\lib\avalon-framework-cvs-20020806.jar;
%CONFIG%\xslt\fop\lib\jimi-1.0.jar;
%CONFIG%\xslt\fop\lib\jai_core.jar;
%CONFIG%\xslt\fop\lib\jai_codec.jar
" />
</ENVIRONMENT>
-->

A hint from Ludger Pottmeier: The "exec" part must not contain "&quot" entities, Windows NT requires to omit them. This is not happening with Windows 2000 and only affects the parameter section.

Replace the batch file with the following:

@echo off
set LIBDIR=lib
set LOCALCLASSPATH=build/fop.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xml-apis.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xercesImpl-2.2.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan-2.4.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-cvs-20020806.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_codec.jar
java -cp %LOCALCLASSPATH% org.apache.fop.apps.Fop -xml %1 -xsl %2 -pdf %4
echo ^<FRAMESET COLS="*"^> >> %3
echo ^<FRAME SRC= %4 /^>>> %3
echo ^</FRAMESET^> >> %3

After restarting Cooktop the FOP transformation should be working. You can extract the a complete zip archive to the installation directory of cooktop.

zurück zum Anfang