5 users online. Create an account or sign in to join them.Users
Alphabet
This is an open discussion with 3 replies, filed under XSLT.
Search
Thanks, great utility! May I suggest an addition? :-)
If you put the actual rendering of the letter and link in a separate template like so
<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>
The developer could easily override the default display according to his needs without having to modify your utility but instead copying the template to his/her page or master.xsl template.
Alphabet updated to version 1.0.1 on 9th of November 2011
Thanks phoque! I updated the utility on your recommendations.
Create an account or sign in to comment.
A new XSLT utility, "Alphabet" is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.