|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Sorting Index alphabetically
Hi Shailesh,
On 11/24/05, shailesh <shailesh@xxxxxxxxxxxx> 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','ABCDEFGHIJKLMNOPQRST
UVWXYZ'),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(transl
ate(.,$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 :-)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








