XML:
<?xml version="1.0" encoding="windows-1251"?>
<mode>
<term>
<name>abhdk</name>
</term>
<term>
<name>njhjsu</name>
</term>
<term>
<name>sdasd</name>
</term>
<term>
<name>vbvbcd</name>
</term>
...
</mode>
<mode>
<term>
<name>asdfd</name>
</term>
<term>
<name>vcbbn</name>
</term>
<term>
<name>bnmbnmb</name>
</term>
<term>
<name>tyutyu</name>
</term>
<term>
<name>ghjghj</name>
</term>
<term>
<name>hjk</name>
</term>
...
</mode>
<mode>
<term>
<name>asdfd</name>
</term>
<term>
<name>vcbbn</name>
</term>
</mode>
...
I need to do Alphabet index like this:
I get template from here: link text
My problem: for each mode
there must be its own "Alphabet index" list (for single mode it works perfectly).
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" encoding="windows-1251"/>
<xsl:for-each select="mode">
<xsl:call-template name="alphabetIndexTmpl">
<xsl:with-param name="key-name" select="'items-key'" />
...
</xsl:call-template>
</xsl:for-each>
<xsl:key name="items-key" match="term" use="substring(., 1, 1)" />
<xsl:template name="alphabetIndexTmpl">
<xsl:param name="key-name"/>
...
</xsl:template>
</xsl:stylesheet>
This code does not work correctly. It has to be corrected like this:
<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" encoding="windows-1251"/>
<xsl:for-each select="mode">
<xsl:call-template name="alphabetIndexTmpl">
<xsl:with-param name="key-name" select="concat('items-key', position())" />
...
</xsl:call-template>
</xsl:for-each>
<xsl:key name="items-key1" match="mode[1]/term" use="substring(., 1, 1)" />
<xsl:key name="items-key2" match="mode[2]/term" use="substring(., 1, 1)" />
<xsl:key name="items-key3" match="mode[2]/term" use="substring(., 1, 1)" />
...
<xsl:template name="alphabetIndexTmpl">
<xsl:param name="key-name"/>
...
</xsl:template>
</xsl:stylesheet>
But it is very crooked decision.
How to solve this problem more elegantly?
Dimitre Novatchev, do not beat me down for "inaccuracies", I surrender my arms)).