Connecting Tech Pros Worldwide Help | Site Map

adding a footer in xsl fo

Familiar Sight
 
Join Date: Jun 2008
Posts: 164
#1: Dec 19 '08
Hi,

I am trying to add page numbers to my document in xsl fo. I can get the page numbers to work but I need them to show at the bottom of each page. I know you can define an area as region-after but don't know how. Heres my xsl file so far.

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-1" ?> 
  2. <xsl:stylesheet version="1.0"
  3.       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4.       xmlns:fo="http://www.w3.org/1999/XSL/Format"
  5.       xmlns:xlink="http://www.w3.org/1999/xlink">
  6.   <xsl:output method="xml" indent="yes"/>
  7.   <xsl:template match="/">
  8.     <fo:root>
  9.       <fo:layout-master-set>
  10.         <fo:simple-page-master master-name="A4"
  11.               page-height="29.7cm" page-width="21.0cm" margin="1cm">
  12.           <fo:region-body/>
  13.         </fo:simple-page-master>
  14.  
  15.       </fo:layout-master-set>
  16.  
  17.       <fo:page-sequence master-reference="A4">
  18.         <fo:flow flow-name="xsl-region-body">
  19.             <fo:block-container absolute-position="absolute"
  20.             top="-2cm" left="-3cm" width="670" height="947px"
  21.             background-image="file:background.gif">
  22.             <fo:block/>
  23.           </fo:block-container>
  24.  
  25.               <fo:block font-family="Helvetica" font-size="18pt" text-align="end" space-before="5px">
  26.                 Date: <xsl:value-of select="quote/project/date"/>
  27.               </fo:block>
  28.               <fo:block font-family="Helvetica" font-size="18pt" text-align="end" space-before="5px">
  29.                 Project Manager: <xsl:value-of select="quote/project/proj_manager"/>
  30.               </fo:block>
  31.             <fo:block font-family="Helvetica" font-size="18pt" text-align="end" space-before="1cm">
  32.                 <xsl:value-of select="quote/project/comp_name"/>
  33.               </fo:block>
  34.               <fo:block font-family="Helvetica" font-size="18pt" text-align="end" space-after="20cm">
  35.                   <xsl:value-of select="quote/project/project_name"/>
  36.               </fo:block>
  37.  
  38.               <fo:block font-family="Helvetica" font-size="10pt" text-align="center" space-before="3cm">
  39.                 18 Derryloran Industrial Estate
  40.               </fo:block>
  41.               <fo:block font-family="Helvetica" font-size="10pt" text-align="center">
  42.                 Sandholes Road
  43.               </fo:block>
  44.               <fo:block font-family="Helvetica" font-size="10pt" text-align="center">
  45.                 Cookstown
  46.               </fo:block>
  47.               <fo:block font-family="Helvetica" font-size="10pt" text-align="center">
  48.                 Co. Tyrone
  49.               </fo:block>
  50.               <fo:block font-family="Helvetica" font-size="10pt" text-align="center">
  51.                 Tel: (028) 8676 1141    Fax: (028) 8676 9732    Email: info@tes-ni.com
  52.               </fo:block>
  53.  
  54.               <!-- Nextpage: Quote -->
  55.                <fo:block break-before="page" space-before="2in" space-after="2in">
  56.  
  57.                  <fo:block text-align="center" space-before="2cm" font-weight="bold" font-size="18pt">
  58.                 PANELS
  59.                 </fo:block>
  60.                 <fo:table space-before="1cm">
  61.                   <fo:table-body>
  62.                   <xsl:for-each select="quote/panels/panel">
  63.                         <fo:table-row>
  64.                       <fo:table-cell padding="6pt">
  65.                         <fo:block text-align="start"><xsl:value-of select="panel_name"/></fo:block>
  66.                       </fo:table-cell>
  67.                       <fo:table-cell padding="6pt">
  68.                         <fo:block text-align="end" space-after="2cm">£<xsl:value-of select="totalcost"/></fo:block>
  69.                       </fo:table-cell>
  70.                     </fo:table-row>
  71.                     </xsl:for-each>
  72.                     <fo:table-row>
  73.                         <fo:table-cell>
  74.                             <fo:block text-align="start" font-weight="bold" border-top="0.5pt solid red">Sub Total</fo:block>
  75.                         </fo:table-cell>
  76.                         <fo:table-cell>
  77.                             <fo:block font-weight="bold" text-align="end" border-top="0.5pt solid red">£<xsl:value-of select="sum(quote/panels/panel/totalcost)"/></fo:block>
  78.                         </fo:table-cell>
  79.                         </fo:table-row>
  80.                         </fo:table-body>
  81.                 </fo:table>
  82.  
  83.  
  84.  
  85.  
  86.                     <fo:block text-align="center" space-before="2cm" font-weight="bold" font-size="18pt">
  87.                 ADDITIONAL ITEMS
  88.                 </fo:block>
  89.                     <fo:table space-before="1cm">
  90.                   <fo:table-body>
  91.                         <xsl:for-each select="quote/project/extras/item">
  92.                         <fo:table-row>
  93.                         <fo:table-cell padding="6pt">
  94.                             <fo:block text-align="start"><xsl:value-of select="ex_item"/></fo:block>
  95.                         </fo:table-cell>
  96.                         <fo:table-cell padding="6pt">
  97.                             <fo:block text-align="end">£<xsl:value-of select="ex_cost"/></fo:block>
  98.                         </fo:table-cell>
  99.                         </fo:table-row>
  100.                         <fo:table-row>
  101.                         <fo:table-cell padding="6pt" number-columns-spanned="2">
  102.                             <fo:block font-style="italic" text-align="start"><xsl:value-of select="ex_description"/></fo:block>
  103.                         </fo:table-cell>
  104.                         </fo:table-row>
  105.                         </xsl:for-each>
  106.                         <fo:table-row>
  107.                         <fo:table-cell>
  108.                             <fo:block text-align="start" font-weight="bold" border-top="0.5pt solid red">Sub Total</fo:block>
  109.                         </fo:table-cell>
  110.                         <fo:table-cell>
  111.                             <fo:block font-weight="bold" text-align="end" border-top="0.5pt solid red">£<xsl:value-of select="sum(quote/project/extras/item/ex_cost)"/></fo:block>
  112.                         </fo:table-cell>
  113.                         </fo:table-row>
  114.                   </fo:table-body>
  115.                 </fo:table>
  116.                 <fo:table space-before="1cm">
  117.                   <fo:table-body>
  118.                   <fo:table-row>
  119.                         <fo:table-cell>
  120.                             <fo:block text-align="start" font-weight="bold" border-top="0.5pt solid red" font-size="18pt">Total Cost</fo:block>
  121.                         </fo:table-cell>
  122.                         <fo:table-cell>
  123.                             <fo:block font-weight="bold" text-align="end" border-top="0.5pt solid red" font-size="18pt">£<xsl:value-of select="sum(quote/project/extras/item/ex_cost)+sum(quote/panels/panel/totalcost)"/></fo:block>
  124.                         </fo:table-cell>
  125.                         </fo:table-row>
  126.                   </fo:table-body>
  127.                 </fo:table>
  128.                 </fo:block>
  129.  
  130.                 <fo:block text-align="center">Page <fo:page-number/></fo:block>
  131.  
  132.  
  133.                 <!-- Nextpage: Quotation Terms -->
  134.                    <fo:block break-before="page" space-before="2in" space-after="2in">
  135.                    <fo:block text-align="start" space-before="2cm" font-size="18pt" font-weight="bold">
  136.                 PAYMENT TERMS
  137.                 </fo:block>
  138.                 <fo:block font-family="Helvetica" font-size="12pt" text-align="start" space-before="1cm">
  139.                 <xsl:value-of select="quote/project/extras/payment"/>
  140.                   </fo:block>
  141.  
  142.                 <fo:block text-align="start" space-before="2cm" font-size="18pt" font-weight="bold">
  143.                 DELIVERY TERMS
  144.                 </fo:block>
  145.                 <fo:block font-family="Helvetica" font-size="12pt" text-align="start" space-before="1cm">
  146.                 <xsl:value-of select="quote/project/extras/delivery"/>
  147.                   </fo:block>
  148.  
  149.                 <fo:block text-align="start" space-before="2cm" font-size="18pt" font-weight="bold">
  150.                 VALIDITY
  151.                 </fo:block>
  152.                 <fo:block font-family="Helvetica" font-size="12pt" text-align="start" space-before="1cm">
  153.                 <xsl:value-of select="quote/project/extras/valid_for"/>
  154.                   </fo:block>
  155.                    </fo:block>
  156.                    <fo:block text-align="center">Page <fo:page-number/></fo:block>
  157.  
  158.                    <!-- Nextpage: Our Company -->
  159.                    <fo:block break-before="page" space-before="2in" space-after="2in">
  160.                        <fo:block text-align="center" space-before="6cm" font-size="18pt" font-weight="bold">
  161.                     OUR COMPANY
  162.                     </fo:block>
  163.                     <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  164.                     TES are a multi-faceted company, working to the highest standard of engineering excellence.  Innovative and dynamic, TES are established in a number of industries offering professional and quality services to include;
  165.                     </fo:block>
  166.  
  167.  
  168.                     <fo:list-block space-before="1cm"> 
  169.                         <fo:list-item >
  170.                         <fo:list-item-label end-indent="label-end()" >
  171.                           <fo:block space-before="1cm">
  172.                           1)
  173.                           </fo:block>
  174.                         </fo:list-item-label>
  175.                         <fo:list-item-body start-indent="body-start()" >
  176.                         <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  177.                             Mechanical and Electrical Services to the Water Treatment Industry
  178.                         </fo:block>
  179.                         </fo:list-item-body>
  180.                         </fo:list-item>
  181.  
  182.                         <fo:list-item >
  183.                         <fo:list-item-label end-indent="label-end()" >
  184.                           <fo:block space-before="1cm">
  185.                           2)
  186.                           </fo:block>
  187.                         </fo:list-item-label>
  188.                         <fo:list-item-body start-indent="body-start()" >
  189.                         <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  190.                             Design, manufacture and installation of electrical control panels
  191.                         </fo:block>
  192.                         </fo:list-item-body>
  193.                         </fo:list-item>
  194.  
  195.                         <fo:list-item >
  196.                         <fo:list-item-label end-indent="label-end()" >
  197.                           <fo:block space-before="1cm">
  198.                           3)
  199.                           </fo:block>
  200.                         </fo:list-item-label>
  201.                         <fo:list-item-body start-indent="body-start()" >
  202.                         <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  203.                             Integrated SCADA and PLC Software
  204.                         </fo:block>
  205.                         </fo:list-item-body>
  206.                         </fo:list-item>
  207.  
  208.                         <fo:list-item >
  209.                         <fo:list-item-label end-indent="label-end()" >
  210.                           <fo:block space-before="1cm">
  211.                           4)
  212.                           </fo:block>
  213.                         </fo:list-item-label>
  214.                         <fo:list-item-body start-indent="body-start()" >
  215.                         <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  216.                             Full range of bespoke Building Services Solutions
  217.                         </fo:block>
  218.                         </fo:list-item-body>
  219.                         </fo:list-item>
  220.                     </fo:list-block>
  221.                     <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  222.                     Committed to exceeding client expectations, TES, with our team of experienced designers and engineers remain focused on offering pioneering solutions and expert design services.  
  223.                     </fo:block>
  224.                     <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  225.                     Our Project Management team are renown for the skilled execution of professional engineering and management services ensuring that each project is delivered to the highest standard in a timely and efficient manner.
  226.                     </fo:block>
  227.                     <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  228.                     With a proven track record in the delivery of high value public and private sector projects, TES never fail to deliver.  Fully committed to deploying stringent Health and Safety Policies, Quality standards and Environmental procedures, TES are without question a socially responsible business.
  229.                     </fo:block>
  230.                     <fo:block text-align="justify" space-before="1cm" font-size="12pt">
  231.                     A fast-moving and forward thinking organisation, TES offer fully integrated engineering services in an expert and highly professional manner.  Our reputation exceeds us as offering a client-focused service through quality workmanship.  This is why our company mantra remains;
  232.                     </fo:block>
  233.                     <fo:block text-align="center" space-before="2cm" font-size="16pt" font-weight="bold">
  234.                     Quality Driven....Customer Focused
  235.                     </fo:block>
  236.                     <fo:block text-align="center">Page <fo:page-number/></fo:block>
  237.  
  238.                     <xsl:for-each select="quote/panels/panel">
  239.                     <!-- Nextpage: SVG Drawings -->
  240.                     <fo:block break-before="page">
  241.  
  242.                        <fo:instream-foreign-object>
  243.  
  244.                     <svg xmlns="http://www.w3.org/2000/svg" width="29.7cm" height="29.7cm" xml:space="preserve">
  245.  
  246.                         <g transform="rotate(-90)">
  247.                             <image xlink:href="{svgdrawing/text()}" x="-27cm" y="1cm" width="70cm" height="40cm"/> 
  248.  
  249.  
  250.                           </g>
  251.  
  252.                     </svg>
  253.  
  254.                     </fo:instream-foreign-object>
  255.  
  256.                        </fo:block>
  257.                     </xsl:for-each>
  258.  
  259.  
  260.  
  261.                    </fo:block>
  262.  
  263.  
  264.  
  265.         </fo:flow>
  266.  
  267.       </fo:page-sequence>
  268.  
  269.  
  270.  
  271.     </fo:root>
  272.   </xsl:template>
  273. </xsl:stylesheet>
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#2: Dec 19 '08

re: adding a footer in xsl fo


I haven't done xsl-fo much, but that's the reference: XSL 1.1 – fo:region-after
Reply