[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to create index entry in xsl file?

Subject: Re: How to create index entry in xsl file?
From: "Vasu Chakkera" <vasucv@xxxxxxxxx>
Date: Mon, 22 Dec 2008 14:20:20 +0000
Re:  How to create index entry in xsl file?
Please take a look at the stylesheets in the docbook sourceforge.
http://docbook.sourceforge.net/release/xsl/current/doc/

(that is if you are using the docbook dtd)

Most of these have a ready made solution..

Vasu


On 22/12/2008, Kalpana Pathak <pathak.kalpana@xxxxxxxxx> wrote:
> Hello everyone,
>
> I would like to generate the indexes in the PDF output. I typed the
> following elements in the xsl file, but it is giving me error. Can
> someone guide me to what are the attributes/parameters i need to put
> in the xsl file to generate the index.
>
>   <xsl:key name="letter" match="indexterm" use="substring(primary,1,1)"/>
>
>   <xsl:key name="letter" match="indexterm"
>            use="translate(substring(primary,1,1),
>                           'abcdefghijklmnopqrstuvwxyz',
>                         'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
>   <xsl:apply-templates select="//indexterm[count(.|
>                                  key('letter',
>                                    translate(substring(primary,1,1),
>                                      'abcdefghijklmnopqrstuvwxyz',
>                                      'ABCDEFGHIJKLMNOPQRSTUVWXYZ'))[1])
>                                  = 1]"
>                        mode="index-div">
>     <xsl:sort select="translate(primary, 'abcdefghijklmnopqrstuvwxyz',
>                                          'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
>   </xsl:apply-templates>
>   <xsl:key name="primary" match="indexterm" use="primary"/>
>
>   <xsl:template match="indexterm" mode="index-div">
>     <!-- Get the group key (ie. first letter of index terms in this group
> -->
>     <xsl:variable name="key"
>                   select="translate(substring(primary,1,1),
>                                     'abcdefghijklmnopqrstuvwxyz',
>                                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
>
>     <!-- Output label for current index group -->
>     <xsl:value-of select="$key"/>
>
>     <xsl:apply-templates select="key('letter', $key)
>                                  [count(.|key('primary',primary)[1])=1]"
>                          mode="index-primary">
>       <xsl:sort select="translate(primary,
>                                   'abcdefghijklmnopqrstuvwxyz',
>                                   'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
>     </xsl:apply-templates>
>   </xsl:template>
>
>   <xsl:key name="primary" match="indexterm" use="primary"/>
>
>    <xsl:template match="indexterm" mode="index-primary">
>
>     <!-- Find all occurences of index term -->
>     <xsl:variable name="refs" select="key('primary', primary)"/>
>
>     <!-- Output text of index term -->
>     <xsl:value-of select="primary"/>
>
>     <xsl:for-each select="$refs[not(secondary)]">
>       <!-- Create page number reference (print) or link with back
>            reference (HTML) to each occurrence of the index term -->
>     </xsl:for-each>
>
>     <xsl:if test="$refs/secondary">
>        <!-- Process secondary level entries -->
>     </xsl:if>
>    </xsl:template>
>
> Thanks in advance,
> Kalpana
>
>


-- 
Vasu Chakkera
Numerical Algorithms Group Ltd.
Oxford
www.vasucv.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.