Hi Shailesh,
On 11/24/05, shailesh <shailesh(_at_)quagnito(_dot_)net> wrote:
How do I sort index alphabetically using xsl.
This is both a grouping and a sorting problem.
I would recommend looking through the various sites about grouping, for example:
http://dpawson.co.uk/xsl/sect2/N4486.html#d5052e16 and
http://jenitennison.com/xslt/grouping/index.xml
A quick (untried) solution is here below.
<xsl:key name="first-letter" match="Keyword"
use="substring(translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),1,1)"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<!-- Iterate through each letter -->
<xsl:for-each
select="Keyword[generat-id(.)=generate-id(key('first-letter',substring(translate(.,$lower,$upper),1,1)))]">
<xsl:sort select="substring(translate(.,$lower,$upper),1,1))"/>
<h2><xsl:value-of select="substring(translate(.,$lower,$upper),1,1))"/></h2>
<!-- Iterate through each word starting with current letter -->
<xsl:for-each
select="key('first-letter',substring(translate(.,$lower,$upper),1,1))">
<xsl:sort select="."/>
<xsl:value-of select="."/><br/>
</xsl:for-each>
</xsl:for-each>
I hope this helps you in the right direction.
Regards,
Ragulf Pickaxe :-)
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--