Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Generation of a table of contents using XSL - FOP

Reply
Thread Tools

Generation of a table of contents using XSL - FOP

 
 
Avi
Guest
Posts: n/a
 
      06-19-2007
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"
xmlnssl="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>

<foage-sequence master-reference="simple">
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="FILE"/>
</fo:flow>
</foage-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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache FOP to load images with data url in PDF using xsl-fo Edward Java 2 05-18-2007 02:07 PM
Problems running Apache FOP: org.apache.fop.fo.FOTreeBuilder fatalError Pablo Java 0 03-28-2007 02:31 PM
NullPointer Exception in class SAX2DTM during FOP generation with SAX Parser Jens Mueller Java 0 04-12-2005 04:28 PM
Using Wingdings in xsl:fo for rendering with FOP Veerle XML 0 04-07-2005 10:14 AM
Unwanted whitespace after xsl:value-of when using fop Brynjar Glesnes XML 3 08-31-2004 12:22 AM



Advertisments