Page 1 of 1

Generate linked alphabet for index

Posted: Mon Jan 23, 2017 12:27 pm
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

Re: Generate linked alphabet for index

Posted: Tue Jan 24, 2017 10:07 am
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

Re: Generate linked alphabet for index

Posted: Tue Jan 24, 2017 6:19 pm
by ann.jensen
Thank you so much for that.
It works a treat :-)
Ann