bdelacretaz 2003/05/01 07:00:19
Modified: src/blocks/fop/samples sitemap.xmap
src/blocks/fop/samples/misc samples.xml
src/webapp/samples/xsp/xsp cacheable.xsp
Added: src/blocks/fop/samples/cache-test xsp-sample-to-fo.xsl
Log:
FOP caching test added (but PDF caching does not work yet)
Revision Changes Path
1.2 +9 -0 cocoon-2.1/src/blocks/fop/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/fop/samples/sitemap.xmap,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sitemap.xmap 1 May 2003 11:23:27 -0000 1.1
+++ sitemap.xmap 1 May 2003 14:00:19 -0000 1.2
@@ -115,6 +115,15 @@
<map:serialize type="fo2pdf"/>
</map:match>
+ <!-- reuse the XSP caching example for our caching test -->
+ <map:match pattern="cache-test-*-*-*.pdf">
+ <map:generate
src="cocoon://samples/xsp/java/cacheable?pageKey={1}&other={2}&validity=30"/>
+ <map:transform src="cache-test/xsp-sample-to-fo.xsl">
+ <map:parameter name="pages" value="{3}"/>
+ </map:transform>
+ <map:serialize type="fo2pdf"/>
+ </map:match>
+
</map:pipeline>
</map:pipelines>
1.1
cocoon-2.1/src/blocks/fop/samples/cache-test/xsp-sample-to-fo.xsl
Index: xsp-sample-to-fo.xsl
===================================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
Convert the output of the XSP caching sample to XSL-FO,
in order to test caching of the whole pipeline, up to PDF
@author [EMAIL PROTECTED]
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
>
<xsl:param name="pages" select="'10'"/>
<xsl:attribute-set name="title">
<xsl:attribute name="font-size">18pt</xsl:attribute>
<xsl:attribute name="space-before">10pt</xsl:attribute>
<xsl:attribute name="color">blue</xsl:attribute>
</xsl:attribute-set>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout for all pages -->
<fo:simple-page-master master-name="main"
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:layout-master-set>
<!-- content -->
<fo:page-sequence master-reference="main">
<fo:flow flow-name="xsl-region-body">
<fo:block space-before="6pt">
<fo:block font-size="24pt">Cocoon FOP caching
test</fo:block>
<xsl:call-template name="explain"/>
<xsl:element name="fo:block"
use-attribute-sets="title">
Original output from the XSP page
</xsl:element>
<fo:block color="grey">
<xsl:apply-templates/>
</fo:block>
<xsl:element name="fo:block"
use-attribute-sets="title">
Dummy pages
</xsl:element>
<fo:block>
Several dummy pages follow, as set by the
<fo:inline font-style="italic">pages</fo:inline>
URL parameter.
</fo:block>
<xsl:call-template name="repeatPages">
<xsl:with-param name="nPages" select="$pages"/>
</xsl:call-template>
<fo:block id="lastBlock">
End of test document
</fo:block>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<!-- generate a lot of pages to make FOP generation slower -->
<xsl:template name="repeatPages">
<xsl:param name="nPages"/>
<fo:block break-before="page">
Dummy page, used to slow down FOP generation to test caching...
<xsl:value-of select="$nPages"/> pages to go.
</fo:block>
<fo:block>
<!-- slow down FOP for this test, forcing it to keep all pages in
memory -->
The last page is number <fo:page-number-citation
ref-id="lastBlock"/>.
</fo:block>
<xsl:if test="$nPages > 1">
<xsl:call-template name="repeatPages">
<xsl:with-param name="nPages" select="$nPages - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- explain this sample -->
<xsl:template name="explain">
<xsl:element name="fo:block" use-attribute-sets="title">
What's this?
</xsl:element>
<fo:block>
This sample takes the output of the XSP cacheable sample and
allows you
to test caching all the way up to PDF generation.
</fo:block>
<fo:block>
Note that I haven't been able to get PDF caching to work yet, I'm
checking
this sample in to have a reference for testing. Currently I see
(from the timestamps
written in the generated XML) that the XSP output is indeed
cached, but the sitemap
log shows that the FOP conversion runs for every request.
</fo:block>
<xsl:element name="fo:block" use-attribute-sets="title">
How to test the cache
</xsl:element>
<fo:block>
Call this page like
<fo:inline
font-style="italic">cache-test-keyA-xyz-1500.pdf</fo:inline>,
and use the information shown in
<fo:inline color="red">red</fo:inline> under
<fo:inline font-style="italic">original output</fo:inline>
below to check that the cache is working.
</fo:block>
<fo:block>
In the above filename, <fo:inline
font-style="italic">keyA</fo:inline> is the key used
to store the content generated by the XSP page in cache, and
<fo:inline font-style="italic">1500
</fo:inline>is the number of pages to generate in the output PDF.
</fo:block>
<fo:block>
The sitemap log (or whatever log the FOPSerializer is configured
to write to) can also
be used to tell if FOP is converting the data or if its being
served from the Cocoon cache.
</fo:block>
<fo:block>
Different values of
<fo:inline font-style="italic">pageKey</fo:inline> should cause
different versions of the document to be cached.
</fo:block>
<fo:block>
Increase the
<fo:inline font-style="italic">pages</fo:inline> parameter to
have FOP take longer to generate the document if needed.
</fo:block>
</xsl:template>
<!-- minimal HTML scraping of input -->
<xsl:template match="*[starts-with(name(),'h')]|p">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- minimal HTML scraping of input -->
<xsl:template match="br">
<fo:block> </fo:block>
</xsl:template>
<!-- minimal HTML scraping of input -->
<xsl:template match="b">
<fo:inline color="red" font-weight="bold" font-size="14pt">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
</xsl:stylesheet>
1.2 +9 -0 cocoon-2.1/src/blocks/fop/samples/misc/samples.xml
Index: samples.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/fop/samples/misc/samples.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- samples.xml 1 May 2003 11:23:27 -0000 1.1
+++ samples.xml 1 May 2003 14:00:19 -0000 1.2
@@ -14,6 +14,15 @@
</sample>
</group>
+ <group name="XSP + FOP caching test">
+ <sample name="Generate PDF with pageKey=ONE"
href="cache-test-ONE-a-250.pdf">
+ Needs the XSP block to generate input, see generated document
for info.
+ </sample>
+ <sample name="Same with pageKey=TWO" href="cache-test-TWO-b-225.pdf">
+ Same with another pageKey to check that both are cached
separately.
+ </sample>
+ </group>
+
<group name="Resources">
<sample name="FOP web site" href="http://xml.apache.org/fop">
FOP reference information
1.4 +11 -1 cocoon-2.1/src/webapp/samples/xsp/xsp/cacheable.xsp
Index: cacheable.xsp
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/xsp/xsp/cacheable.xsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- cacheable.xsp 1 May 2003 13:00:22 -0000 1.3
+++ cacheable.xsp 1 May 2003 14:00:19 -0000 1.4
@@ -1,6 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- CVS: $Id$ -->
+<!--
+ XSP caching sample.
+
+ WARNING - another sample depends on this!
+ The output of this is used by the FOP cache test - if you modify this
page, please make sure that
+ the caching samples found at http://localhost:8888/samples/fop/welcome
(or equivalent)
+ still work .
+
+ $Id$
+ -->
+
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"