Alphabet
Display the alphabet
Description
This template is designed to display the alphabet in the form of links (or whatever you like, decide for yourself). By default, it displays the English alphabet.
The original algorithm is taken from the article "XSLT-examples. Vol.3 Index funds XSLT" (Russian).
XSLT
View Raw
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="alphabet"> <!-- en --> <xsl:param name="s" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/> <xsl:variable name="a"> <xsl:value-of select="substring($s,1,1)"/> </xsl:variable> <xsl:variable name="s0"> <xsl:value-of select="substring-after($s,$a)"/> </xsl:variable> <xsl:if test="$s != ''"> <xsl:call-template name="alphabet-item"> <xsl:with-param name="a" select="$a"/> </xsl:call-template> <xsl:call-template name="alphabet"> <xsl:with-param name="s" select="$s0"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="alphabet-item"> <!-- copy this template to your page XSL, then modify it to change the default display behaviour --> <xsl:param name="a" select="''" /> <a href="#{$a}"><xsl:value-of select="$a"/></a> </xsl:template> </xsl:stylesheet>