Generate linked alphabet for index

Post here questions and problems related to editing and publishing DITA content.
ann.jensen
Posts: 295
Joined: Wed Jun 17, 2015 10:19 am

Generate linked alphabet for index

Post by ann.jensen »

Hi,
I have had a client request to generate an alphabet with linked letters at the top of indexTerms.html to provide quick access to the index contents for a given letter e.g. T.
Can anyone advise on where such a customisation would be implemented?
Thanks in advance,
Ann
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: Generate linked alphabet for index

Post by Radu »

Hi Ann,

Interesting idea, I will also add an improvement request for this to our internal issues list.
I assume you want this for WebHelp Responsive.
In the XSLT stylesheet:

OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT2.x\plugins\com.oxygenxml.webhelp\xsl\dita\responsive\createMainFilesImpl.xsl

there is an XSLT template which generates the entire index list grouping index terms in categories:

Code: Select all

 <xsl:template match="index:index" mode="create-index">

......................
in that XSLT template, after the variable named "collation" is defined you can iterate all existing letter categories and create a list of links:

Code: Select all

    <xsl:for-each-group select="index:term" group-by="
upper-case(
translate(
substring(
normalize-unicode(@sort-as, 'NFD'), 1, 1), $katakana_chars, $hiragana_chars))"
collation="{$collation}">
<a href="#index_category_{current-grouping-key()}"><xsl:value-of select="current-grouping-key()"/></a>
<xsl:text> </xsl:text>
</xsl:for-each-group>
Further down, for each letter a list item is created:

Code: Select all

<li class="wh_term_group">
........
and you need to set an @id attribute on it so that the links to it start working:

Code: Select all

<li class="wh_term_group" id="index_category_{current-grouping-key()}">
..............
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ann.jensen
Posts: 295
Joined: Wed Jun 17, 2015 10:19 am

Re: Generate linked alphabet for index

Post by ann.jensen »

Thank you so much for that.
It works a treat :-)
Ann
Post Reply