Formatting a catalog.

We now take the climbing catalog example with prices being added and incrementally create a series of PDF versions improving from one version to another.

exercise No. 67

A first PDF version of the catalog Create comment in forum


Write a XSL script to generate a starting version climbenriched.start.pdf.


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <fo:root font-size="10pt">
        <fo:simple-page-master master-name="productPage"
          page-width="80mm" page-height="110mm" margin="5mm">
          <fo:region-body margin="15mm"/>
          <fo:region-before extent="10mm"/>
      <xsl:apply-templates select="catalog/product" />

  <xsl:template match="product">
    <fo:page-sequence master-reference="productPage">
      <fo:static-content flow-name="xsl-region-before">
        <fo:block font-weight="bold">
          <xsl:value-of select="title"/>
      <fo:flow flow-name="xsl-region-body">
        <xsl:apply-templates select="description/para"/>

        <fo:block>Price:<xsl:value-of select="@price"/></fo:block>
        <fo:block>Order no:<xsl:value-of select="@id"/></fo:block>

  <xsl:template match="para">
    <fo:block space-after="10px">
      <xsl:value-of select="."/>


Header, page numbers and table formatting

Extend A first PDF version of the catalog by adding page numbers. The order number and prices shall be formatted as tables. Add a ruler to each page's head. The result should look like climbenriched.product.pdf


Solution see catalog2fo.product.xsl.

A table of contents.

Each product description's page number shall appear in a table of contents together with the product's title as in climbenriched.toc.pdf.


Solution see catalog2fo.toc.xsl.


Solution see catalog2fo.toclink.xsl.

A final version.

Add the following features:

  1. Number the table of contents starting with page i, ii, iii, iv and so on. Start the product descriptions with page 1. On each page's footer a text page xx of yy shall be displayed. This requires the definition of an anchor id on the FO document's last page.

  2. Add PDF bookmarks by using XEP's FO extensions. This requires the namespace declaration xmlns:rx="" in the XSLT script's header.

The result may look like N.B.: It may take some effort to achieve this result. This effort is left to the interested participants.


Solution see catalog2fo.toclink.xsl.