You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2008/11/07 17:24:57 UTC

svn commit: r712183 - in /cocoon/cocoon3/trunk: cocoon-docs/src/changes/ cocoon-optional/ cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/ cocoon-optional/src/main/resources/META-INF/ cocoon-optional/src/main/resour...

Author: reinhard
Date: Fri Nov  7 08:24:12 2008
New Revision: 712183

URL: http://svn.apache.org/viewvc?rev=712183&view=rev
Log:
COCOON3-7 Add a FOP serializer to the cocoon-optional module
Upgrade Spring to 2.5.6

Added:
    cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/
    cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java   (with props)
    cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/
    cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/
    cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/
    cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml   (with props)
    cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/
    cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java   (with props)
    cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/
    cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml   (with props)
    cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl   (with props)
    cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java   (with props)
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml   (with props)
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl   (with props)
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml   (with props)
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml   (with props)
Modified:
    cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml
    cocoon/cocoon3/trunk/cocoon-optional/pom.xml
    cocoon/cocoon3/trunk/cocoon-sample/pom.xml
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/cocoon3/trunk/parent/pom.xml

Modified: cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml?rev=712183&r1=712182&r2=712183&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml Fri Nov  7 08:24:12 2008
@@ -25,6 +25,9 @@
 <document>
   <body>
     <release version="3.0.0-alpha-2" date="2008-00-00" description="unreleased">
+      <action dev="reinhard" type="add" issue="COCOON3-7" due-to="Simone Tripodi">
+        [cocoon-optional] Add a formatting objects serializer using Apache FOP.
+      </action>
       <action dev="reinhard" type="add">
         [cocoon-sitemap] Add a HTML serializer.
       </action>

Modified: cocoon/cocoon3/trunk/cocoon-optional/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/pom.xml?rev=712183&r1=712182&r2=712183&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-optional/pom.xml Fri Nov  7 08:24:12 2008
@@ -67,7 +67,11 @@
     <dependency>
       <groupId>net.sourceforge.nekohtml</groupId>
       <artifactId>nekohtml</artifactId>
-      <version>1.9.9</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.xmlgraphics</groupId>
+      <artifactId>fop</artifactId>
       <optional>true</optional>
     </dependency>
     <!-- Test libraries -->

Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java Fri Nov  7 08:24:12 2008
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cocoon.optional.pipeline.components.sax.fop;
+
+import java.io.OutputStream;
+
+import org.apache.cocoon.pipeline.ProcessingException;
+import org.apache.cocoon.pipeline.caching.CacheKey;
+import org.apache.cocoon.pipeline.caching.SimpleCacheKey;
+import org.apache.cocoon.pipeline.component.CachingPipelineComponent;
+import org.apache.cocoon.pipeline.component.sax.AbstractSerializer;
+import org.apache.cocoon.pipeline.util.StringRepresentation;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.Fop;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.apps.MimeConstants;
+import org.xml.sax.ContentHandler;
+
+public class FopSerializer extends AbstractSerializer implements CachingPipelineComponent {
+
+    private final static FopFactory FOP_FACTORY = FopFactory.newInstance();
+
+    private String outputFormat;
+
+    /**
+     * Create a new FOP serializer that produces a PDF in output
+     */
+    public FopSerializer() {
+        this(MimeConstants.MIME_PDF);
+    }
+
+    /**
+     * Create a new FOP serializer that produces the specified mime
+     * 
+     * @param outputFormat the output's mime type
+     * @see {@link MimeConstants}
+     */
+    public FopSerializer(String outputFormat) {
+        if (outputFormat == null) {
+            throw new IllegalArgumentException("The parameter 'outputFormat' mustn't be null.");
+        }
+
+        this.outputFormat = outputFormat;
+    }
+
+    @Override
+    public void setOutputStream(OutputStream outputStream) {
+        try {
+            Fop fop = FOP_FACTORY.newFop(this.outputFormat, outputStream);
+            ContentHandler contentHandler = fop.getDefaultHandler();
+
+            this.setContentHandler(contentHandler);
+        } catch (FOPException e) {
+            throw new ProcessingException("Impossible to initialize FOPSerializer", e);
+        }
+    }
+
+    public CacheKey constructCacheKey() {
+        return new SimpleCacheKey();
+    }
+
+    @Override
+    public String toString() {
+        return StringRepresentation.buildString(this, "outputFormat=" + this.outputFormat);
+    }
+}

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml Fri Nov  7 08:24:12 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+<!-- $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <bean name="serializer:fo2pdf" class="org.apache.cocoon.optional.pipeline.components.sax.fop.FopSerializer" scope="prototype" />
+  
+</beans>

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-fop.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java Fri Nov  7 08:24:12 2008
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.optional.pipeline.components.sax.fop;
+
+import static junit.framework.Assert.*;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import org.apache.cocoon.pipeline.NonCachingPipeline;
+import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.pipeline.component.sax.FileGenerator;
+import org.apache.cocoon.pipeline.component.sax.XSLTTransformer;
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+
+public final class FopSerializerTestCase {
+
+    @Test
+    public void testPipelineWithFOPSerializer() throws Exception {
+        Pipeline pipeline = new NonCachingPipeline();
+        pipeline.addComponent(new FileGenerator(this.getClass().getResource("page.xml")));
+        pipeline.addComponent(new XSLTTransformer(this.getClass().getResource("page2fo.xsl")));
+        pipeline.addComponent(new FopSerializer());
+
+        File tmp = File.createTempFile("fop_test_case", ".pdf");
+        FileOutputStream fos = new FileOutputStream(tmp);
+        pipeline.setup(fos);
+        pipeline.execute();
+
+        assertTrue("FOP Serialization didn't work as expected, " + tmp.getAbsolutePath()
+                + " should not be an empty file", tmp.length() > 0);
+
+        FileInputStream fis = new FileInputStream(tmp);
+        String pdfContent = IOUtils.toString(fis);
+        assertTrue(pdfContent.startsWith("%PDF-1.4"));
+
+    }
+}

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/java/org/apache/cocoon/optional/pipeline/components/sax/fop/FopSerializerTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml Fri Nov  7 08:24:12 2008
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<page>
+  <title>Hello</title>
+  <content>
+    <para>This is my first Cocoon PDF page!</para>
+  </content>
+</page>

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl (added)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl Fri Nov  7 08:24:12 2008
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+  <xsl:template match="/">
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="page" page-height="29.7cm" page-width="21cm" margin-top="1cm"
+          margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
+          <fo:region-body margin-top="3cm" />
+          <fo:region-before extent="3cm" />
+          <fo:region-after extent="1.5cm" />
+        </fo:simple-page-master>
+
+        <fo:page-sequence-master master-name="all">
+          <fo:repeatable-page-master-alternatives>
+            <fo:conditional-page-master-reference master-reference="page" page-position="first" />
+          </fo:repeatable-page-master-alternatives>
+        </fo:page-sequence-master>
+      </fo:layout-master-set>
+
+      <fo:page-sequence master-reference="all">
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block text-align="center" font-size="10pt" font-family="serif" line-height="14pt">
+            page <fo:page-number />
+          </fo:block>
+        </fo:static-content>
+
+        <fo:flow flow-name="xsl-region-body">
+          <xsl:apply-templates />
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </xsl:template>
+
+  <xsl:template match="title">
+    <fo:block font-size="36pt" space-before.optimum="24pt" text-align="center">
+      <xsl:apply-templates />
+    </fo:block>
+  </xsl:template>
+
+  <xsl:template match="para">
+    <fo:block font-size="12pt" space-before.optimum="12pt" text-align="center">
+      <xsl:apply-templates />
+    </fo:block>
+  </xsl:template>
+</xsl:stylesheet>

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-optional/src/test/resources/org/apache/cocoon/optional/pipeline/components/sax/fop/page2fo.xsl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java (added)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java Fri Nov  7 08:24:12 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.it;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * Test FOP serialization
+ */
+public class FOPTest extends CocoonHtmlUnitTestCase {
+
+    /**
+     * Create a PDF document
+     */
+    public void testSerializeAsPDF() throws Exception {
+        this.loadResponse("fop/test.pdf");
+        assertTrue(this.response.getStatusCode() == 200);
+        assertEquals("application/pdf", this.response.getContentType());
+
+        String pdfContent = IOUtils.toString(this.response.getContentAsStream());
+        assertTrue(pdfContent.startsWith("%PDF-1.4"));
+    }
+}

Propchange: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/FOPTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/cocoon3/trunk/cocoon-sample/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/pom.xml?rev=712183&r1=712182&r2=712183&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/pom.xml Fri Nov  7 08:24:12 2008
@@ -46,15 +46,21 @@
       <artifactId>cocoon-stringtemplate</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.cocoon.optional</groupId>
-      <artifactId>cocoon-optional</artifactId>
-    </dependency>    
-    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <scope>provided</scope>
     </dependency>    
 
+    <!-- Optional Cocoon libraries -->    
+    <dependency>
+      <groupId>org.apache.cocoon.optional</groupId>
+      <artifactId>cocoon-optional</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.xmlgraphics</groupId>
+      <artifactId>fop</artifactId>
+    </dependency>        
+    
     <!-- Other dependencies -->
     <dependency>
       <groupId>log4j</groupId>

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml Fri Nov  7 08:24:12 2008
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<page>
+  <title>Hello</title>
+  <content>
+    <para>This is my first Cocoon PDF page!</para>
+  </content>
+</page>

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl (added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl Fri Nov  7 08:24:12 2008
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+  <xsl:template match="/">
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="page" page-height="29.7cm" page-width="21cm" margin-top="1cm"
+          margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
+          <fo:region-body margin-top="3cm" />
+          <fo:region-before extent="3cm" />
+          <fo:region-after extent="1.5cm" />
+        </fo:simple-page-master>
+
+        <fo:page-sequence-master master-name="all">
+          <fo:repeatable-page-master-alternatives>
+            <fo:conditional-page-master-reference master-reference="page" page-position="first" />
+          </fo:repeatable-page-master-alternatives>
+        </fo:page-sequence-master>
+      </fo:layout-master-set>
+
+      <fo:page-sequence master-reference="all">
+        <fo:static-content flow-name="xsl-region-after">
+          <fo:block text-align="center" font-size="10pt" font-family="serif" line-height="14pt">
+            page <fo:page-number />
+          </fo:block>
+        </fo:static-content>
+
+        <fo:flow flow-name="xsl-region-body">
+          <xsl:apply-templates />
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </xsl:template>
+
+  <xsl:template match="title">
+    <fo:block font-size="36pt" space-before.optimum="24pt" text-align="center">
+      <xsl:apply-templates />
+    </fo:block>
+  </xsl:template>
+
+  <xsl:template match="para">
+    <fo:block font-size="12pt" space-before.optimum="12pt" text-align="center">
+      <xsl:apply-templates />
+    </fo:block>
+  </xsl:template>
+</xsl:stylesheet>

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/fop/page2fo.xsl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=712183&r1=712182&r2=712183&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Fri Nov  7 08:24:12 2008
@@ -93,5 +93,9 @@
   <ul>
     <li><a href="controller/abc/foo?reqparam=1">Invoke a controller</a>: Invoke a controller and pass two parameters</li>
   </ul>
+  <h2>FOP</h2>
+  <ul>
+  	<li><a href="fop/test.pdf">PDF</a>: Create a PDF document by using Apache FOP.</li>
+  </ul>
   </body>
 </html>

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=712183&r1=712182&r2=712183&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Fri Nov  7 08:24:12 2008
@@ -400,6 +400,14 @@
         <map:serialize type="xhtml" status-code="501" />
       </map:handle-errors>
     </map:pipeline>
+    
+    <map:pipeline>
+      <map:match pattern="fop/test.pdf">
+        <map:generate src="fop/page.xml" />
+        <map:transform src="fop/page2fo.xsl" />
+        <map:serialize type="fo2pdf" />
+      </map:match>
+    </map:pipeline>
 
     <map:handle-errors>
       <map:select value="{jexl:cocoon.exception.class.name}">

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml Fri Nov  7 08:24:12 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+<!-- $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <bean name="serializer:fop" class="org.apache.cocoon.optional.pipeline.components.sax.fop.FopSerializer" scope="prototype" />
+  
+</beans>

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-optional-fop.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml?rev=712183&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml (added)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml Fri Nov  7 08:24:12 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+ -->
+<!-- $Id$ -->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+  <import resource="classpath:META-INF/cocoon/spring-optional/cocoon-optional-fop.xml" />
+  
+</beans>

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/META-INF/cocoon/spring/cocoon-sample-sitemap-components-optional.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cocoon/cocoon3/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/parent/pom.xml?rev=712183&r1=712182&r2=712183&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/parent/pom.xml (original)
+++ cocoon/cocoon3/trunk/parent/pom.xml Fri Nov  7 08:24:12 2008
@@ -130,42 +130,42 @@
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-beans</artifactId>
-        <version>2.5.5</version>
+        <version>2.5.6</version>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-core</artifactId>
-        <version>2.5.5</version>
+        <version>2.5.6</version>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-context</artifactId>
-        <version>2.5.5</version>
+        <version>2.5.6</version>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-dao</artifactId>
-        <version>2.5.5</version>
+        <version>2.5.6</version>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-aop</artifactId>
-        <version>2.5.5</version>
+        <version>2.5.6</version>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-web</artifactId>
-        <version>2.5.5</version>
+        <version>2.5.6</version>
       </dependency>
       <dependency>
         <groupId>org.aspectj</groupId>
         <artifactId>aspectjrt</artifactId>
-        <version>1.5.4</version>
+        <version>1.6.1</version>
       </dependency>
       <dependency>
         <groupId>org.aspectj</groupId>
         <artifactId>aspectjweaver</artifactId>
-        <version>1.5.4</version>
+        <version>1.6.1</version>
       </dependency>
       
       <!-- Hibernate -->
@@ -242,6 +242,11 @@
         <version>3.0</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.xmlgraphics</groupId>
+        <artifactId>fop</artifactId>
+        <version>0.95</version>
+      </dependency>
+      <dependency>
         <groupId>xml-apis</groupId>
         <artifactId>xml-apis</artifactId>
         <version>1.3.02</version>