home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / xsp-sample-to-itext.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.8 KB  |  122 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <!--
  19.     Convert the output of the XSP caching sample to iText,
  20.     in order to test caching of the whole pipeline, up to PDF
  21.  
  22.     @author tcurdt@apache.org
  23.     CVS $Id: xsp-sample-to-itext.xsl,v 1.4 2004/04/22 12:26:00 vgritsenko Exp $
  24. -->
  25.  
  26. <xsl:stylesheet
  27.     version="1.0"
  28.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  29.  
  30.     <xsl:param name="pages" select="'10'"/>
  31.  
  32.     <xsl:template match="/">
  33.       <itext creationdate="Fri May 23 9:30:00 CEST 2003" producer="tcurdt@cocoon.org">
  34.         <xsl:call-template name="explain"/>
  35.         <xsl:call-template name="repeatPages">
  36.           <xsl:with-param name="nPages" select="$pages"/>
  37.         </xsl:call-template>
  38.  
  39.        <paragraph font="unknown" size="12.0" align="Default">
  40.          End of test document
  41.        </paragraph>
  42.       </itext>
  43.     </xsl:template>
  44.  
  45.     <!-- generate a lot of pages to make FOP generation slower -->
  46.     <xsl:template name="repeatPages">
  47.         <xsl:param name="nPages"/>
  48.  
  49.         <paragraph font="unknown" size="12.0" align="Default">
  50.           <newpage/>
  51.           Dummy page, used to slow down iText generation to test caching...
  52.           <xsl:value-of select="$nPages"/> pages to go.
  53.         </paragraph>
  54.  
  55.         <xsl:if test="$nPages > 1">
  56.             <xsl:call-template name="repeatPages">
  57.                 <xsl:with-param name="nPages" select="$nPages - 1"/>
  58.             </xsl:call-template>
  59.         </xsl:if>
  60.     </xsl:template>
  61.  
  62.     <!-- explain this sample -->
  63.     <xsl:template name="explain">
  64.         <phrase leading="27.0" align="Default" font="Helvetica" size="18.0" fontstyle="normal" red="0" green="64" blue="64">
  65.             What's this?
  66.         </phrase>
  67.         <newline/>
  68.         <paragraph font="unknown" size="12.0" align="Default">
  69.             This sample reuses the XSP cacheable sample page and allows you
  70.             to test caching all the way up to PDF generation.
  71.         </paragraph>
  72.         <paragraph font="unknown" size="12.0" align="Default">
  73.             Note that I was unable to get caching to work when using the cocoon:/
  74.             protocol and the FileGenerator to access the output of the XSP sample.
  75.             Using the XSP page directly with the serverpages generator works.
  76.         </paragraph>
  77.         <newline/><newline/>
  78.         <phrase leading="27.0" align="Default" font="Helvetica" size="18.0" fontstyle="normal" red="0" green="64" blue="64">
  79.             How to test the cache
  80.         </phrase>
  81.         <newline/>
  82.         <paragraph font="unknown" size="12.0" align="Default">
  83.             Call this page as described below and use the information shown in
  84.             <chunk font="Helvetica" size="14.0" fontstyle="normal" red="255" green="0" blue="0">red</chunk> under
  85.             <chunk font="Helvetica" size="14.0" fontstyle="normal" red="255" green="0" blue="0">original output</chunk>
  86.             below to check that the cache is working.
  87.         </paragraph>
  88.         <paragraph font="unknown" size="12.0" align="Default">
  89.             The sitemap log (or whatever log the FOPSerializer is configured to write to) can also
  90.             be used to tell if FOP is converting the data or if its being served from the Cocoon cache.
  91.         </paragraph>
  92.         <paragraph font="unknown" size="12.0" align="Default">
  93.             Different values of
  94.             <chunk font="Helvetica" size="14.0" fontstyle="normal" red="255" green="0" blue="0">pageKey</chunk> should cause different versions of the document to be cached.
  95.         </paragraph>
  96.         <paragraph font="unknown" size="12.0" align="Default">
  97.             The number at the end of the page name is the number of pages to generate in the output PDF.
  98.         </paragraph>
  99.     </xsl:template>
  100.  
  101.     <!-- minimal HTML scraping of input -->
  102.     <xsl:template match="*[starts-with(name(),'h')]|p">
  103.         <paragraph font="unknown" size="12.0" align="Default">
  104.             <xsl:apply-templates/>
  105.         </paragraph>
  106.     </xsl:template>
  107.  
  108.     <!-- minimal HTML scraping of input -->
  109.     <xsl:template match="br">
  110.         <newline/>
  111.     </xsl:template>
  112.  
  113.     <!-- minimal HTML scraping of input -->
  114.     <xsl:template match="b">
  115.        <chunk size="20.0" fontstyle="bold" red="255" green="0" blue="0">
  116.  
  117.             <xsl:apply-templates/>
  118.        </chunk>
  119.     </xsl:template>
  120.  
  121. </xsl:stylesheet>
  122.