Home Page FO Designer 2.16. XSL-FO Editor for Apache FOP and Oracle APEX
Home
                                FO Designer
                              • Introduction
                              • Documentation
                              • User guide online
                              • Teamwork
                              • Videos
                              • Version history
                              • PDF interactive forms
                              • Oracle Application Express
                              • APEX Plugin
                              • SAP XI / PI
                              • Oracle BPEL
                              • Mule ESB
                              • Apache Cocoon
                              • License
                              • Apache Cocoon

                                How to use FO Designer with Apache Cocoon

                                Introduction

                                Apache Cocoon is a web development framework which includes a component for XML to PDF conversion. This is achieved by using the so called "PDF serializer". This requires you to create a XSL-FO file which describes how to convert the XML file to PDF. 

                                XSL-FO files created using J4L FO Designer are fully compatible and can be used in Apache Cocoon PDF serializer.

                                Example

                                You can very easily test some of the examples provided with J4L FO designer in your Apache Cocoon server. For this example we assume you have installed Cocoon on a tomcat server in the following subdirectory:

                                c:\tomcat\webapps\cocoon

                                We will create a very simple Cocoon application that converts the file examples\employees\departmentEmployees.xml to PDF. 

                                You must perform the following steps:

                                1. create a directory called 

                                  c:\tomcat\webapps\cocoon\pdfsample

                                2. copy these files from the FO designer distribution  to the c:\tomcat\webapps\cocoon\pdfsample directory:

                                  examples\employees\departmentEmployees.xml
                                  examples\employees\departmentEmployees.fo

                                3. create the file c:\tomcat\webapps\cocoon\pdfsample\sitemap.xmap. This file should contain the following data:

                                  <map:sitemap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                  xsi:schemaLocation="http://apache.org/cocoon/sitemap/1.0 
                                  http://cocoon.apache.org/schema/sitemap/cocoon-sitemap-1.0.xsd"
                                  xmlns:map="http://apache.org/cocoon/sitemap/1.0">

                                  <map:pipelines>
                                  <map:pipeline>

                                  <map:match pattern="employeesPDF">
                                  <map:generate src="departmentEmployees.xml" type="file"/>
                                  <map:transform src="departmentEmployees.fo" type="xslt"/>
                                  <map:serialize type="fo2pdf"/>
                                  </map:match>
                                  </map:pipeline>

                                  </map:pipelines>

                                  </map:sitemap>

                                4. Start the web server (Tomcat)

                                5. Open the following URL in the browser (we assume your server runs on port 8080):

                                  http://localhost:8080/cocoon/pdfsample/employeesPDF

                                6. The browser shows the PDF file.

                                As you can seen in this example, the file departmentEmployees.fo which has been designed with J4L FO Designer has been successfully been executed by Apache Cocoon.