Re: [docbook-apps] Section numbers and titles in PDF indexes

From
Bob Stayton <>
Date
2009-08-27T16:23:02+00:00
ID
0c1801ca2732$9d5630c0$0a00a8c0@pazu
Thread
Re: [docbook-apps] Section numbers and titles in PDF indexes
Hi,
This can be done, but it somewhat depends on which XSL-FO processor you are 
using.  If you are using XEP, then it is a little more complicated because 
XEP has indexing extensions that collapse duplicate page numbers and ranges, 
and the Docbook stylesheets make use of those extensions when when the 
stylesheet parameter xep.extensions=1.

If you are not using XEP, you can customize this template from 
fo/autoidx.xsl:

   <xsl:template match="indexterm" mode="reference">

Where you see:

        <fo:page-number-citation ref-id="{$id}"/>

you can replace it with code to generate the section title.  The $id here is 
the generated id for the indexterm, used in the marker element, which is an 
empty fo element placed as the point destination for the indexterm in the 
body of the document.  So this id won't be used for the section text.

To generate a text string like "3.4 Product Range", you'll need to find the 
appropriate ancestor element of the indexterm.  The same template in 
html/autoidx.xsl has the code for that.  It uses a text entity &section; 
which is defined in common/entities.ent (you'll need to include those entity 
declarations at the top of your customization layer in the same way 
html/autoidx.xsl does).  Then you can generate the number and title with:

<xsl:variable name="container" select="&section;"/>
<xsl:apply-templates select="$container" mode="label.markup"/>
<xsl:text> </xsl:text>
<xsl:apply-templates select="$container" mode="title.markup"/>


Bob Stayton
Sagehill Enterprises



----- Original Message ----- 
From: "Andrew McFarland" <>
To: <>
Sent: Thursday, August 27, 2009 8:28 AM
Subject: [docbook-apps] Section numbers and titles in PDF indexes


> I'd like to have a PDF index with section numbers and section titles
> in the index instead of page numbers.
>
> E.g instead of
>
> widgets .......... 54
>
> Have
>
> widgets........3.4 Product Range
>
> Is this possible? I can't see any easy way to do this. I looked at the
> HTML index template, and only got confused.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> For additional commands, e-mail: 
>
>
>