By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,402 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,402 IT Pros & Developers. It's quick & easy.

Generation of a table of contents using XSL - FOP

P: n/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>
<NAMEA_B </NAME>
<MESSAGEMSG_1 </MESSAGE>
<MESSAGEMSG_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?

Jun 19 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.