Generation of a table of contents using XSL - FOP

A

Avi

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top