Generation of a table of contents using XSL - FOP

Discussion in 'XML' started by Avi, Jun 19, 2007.

  1. Avi

    Avi Guest

    Hello,

    I am trying to generate a TOC using FOP. I have a XML file as follows:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <FILE>
    <INTERFACE>
    <NAME> A_B </NAME>
    <MESSAGE> MSG_1 </MESSAGE>
    <MESSAGE> MSG_2 </MESSAGE>
    </INTERFACE>
    </FILE>

    I want to generate a pdf file with the table of contents as:

    1. A_B
    1.1 MSG_1................................................1
    1.2 MSG_2................................................3

    And these should be linked to the corresponding pages 1 and 3. Is it
    possible to write an XSL file which could do it? I tried with the
    following XSL file, but could not get the desired output.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <xsl:template match="/">

    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <fo:layout-master-set>
    <fo:simple-page-master master-name="simple"
    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>

    <fo:page-sequence master-reference="simple">
    <fo:flow flow-name="xsl-region-body">
    <xsl:apply-templates select="FILE"/>
    </fo:flow>
    </fo:page-sequence>

    </fo:root>
    </xsl:template>

    <xsl:template match="FILE">
    <fo:block font-size="12pt"
    font-family="sans-serif"
    line-height="15pt"
    space-after.optimum="3pt"
    text-align="justify"
    padding-bottom="6pt">
    <xsl:apply-templates select="TOC" />
    </fo:block>
    </xsl:template>

    <xsl:template match="TOC">
    <xsl:apply-templates select="//INTERFACE" mode="toc"/>
    </xsl:template>

    <xsl:template match="INTERFACE" mode="toc">
    <xsl:for-each select="MESSAGE">
    <xsl:number format="1.1.1. " level="multiple" from="s1"
    count="INTERFACE|MESSAGE"/>
    <xsl:value-of select="."/>
    </xsl:for-each>
    </xsl:template>


    </xsl:stylesheet>


    I could not find proper documentation. Could anybody help me wth this?
     
    Avi, Jun 19, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jens Mueller
    Replies:
    0
    Views:
    616
    Jens Mueller
    Apr 12, 2005
  2. Tim
    Replies:
    6
    Views:
    11,578
  3. Edward
    Replies:
    2
    Views:
    11,049
    DerekLittle
    May 18, 2007
  4. Brynjar Glesnes
    Replies:
    3
    Views:
    599
    Patrick TJ McPhee
    Aug 31, 2004
  5. Pablo
    Replies:
    0
    Views:
    974
    Pablo
    Mar 28, 2007
Loading...

Share This Page