cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: cocoon-2.1/src/webapp/samples/xsp/xsp cacheable.xsp
Date Thu, 01 May 2003 14:00:19 GMT
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
  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"/>
  +            <!-- 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}&amp;other={2}&amp;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>
  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
      <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:template match="/">
          <fo:root xmlns:fo="">
                  <!-- layout for all pages -->
                  <fo:simple-page-master master-name="main"
                      <fo:region-body margin-top="3cm"/>
                      <fo:region-before extent="3cm"/>
                      <fo:region-after extent="1.5cm"/>
              <!-- 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
                          <fo:block color="grey">
                          <xsl:element name="fo:block" use-attribute-sets="title">
                              Dummy pages
                              Several dummy pages follow, as set by the
                              <fo:inline font-style="italic">pages</fo:inline>
URL parameter.
                          <xsl:call-template name="repeatPages">
                              <xsl:with-param name="nPages" select="$pages"/>
                          <fo:block id="lastBlock">
                              End of test document
      <!-- 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.
              <!-- 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"/>.
          <xsl:if test="$nPages &gt; 1">
              <xsl:call-template name="repeatPages">
                  <xsl:with-param name="nPages" select="$nPages - 1"/>
      <!-- explain this sample -->
      <xsl:template name="explain">
          <xsl:element name="fo:block" use-attribute-sets="title">
              What's this?
              This sample takes the output of the XSP cacheable sample and allows you
              to test caching all the way up to PDF generation.
              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
              log shows that the FOP conversion runs for every request.
          <xsl:element name="fo:block" use-attribute-sets="title">
              How to test the cache
              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.
              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.
              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.
              Different values of
              <fo:inline font-style="italic">pageKey</fo:inline> should cause
different versions of the document to be cached.
              Increase the
              <fo:inline font-style="italic">pages</fo:inline> parameter to have
FOP take longer to generate the document if needed.
      <!-- minimal HTML scraping of input -->
      <xsl:template match="*[starts-with(name(),'h')]|p">
      <!-- minimal HTML scraping of input -->
      <xsl:template match="br">
      <!-- minimal HTML scraping of input -->
      <xsl:template match="b">
          <fo:inline color="red" font-weight="bold" font-size="14pt">
  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 @@
  +    <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="">
               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"

View raw message