[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: creating a directory-like index

Subject: RE: creating a directory-like index
From: FEDOU <Nfedou@xxxxxxxxxxxx>
Date: Thu, 7 Aug 2003 16:56:00 +0200
creating a directory index
If you have more question about grouping,
you can find good answers at this site :
http://www.jenitennison.com/xslt/grouping/index.html

It was useful to me, I hope Jeni Tennison's website will useful to you too.
Regards,
Nicolas Fédou

> -----Message d'origine-----
> De : Andrew Welch [mailto:AWelch@xxxxxxxxxxxxxxx]
> Envoyé : jeudi 7 août 2003 15:47
> À : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Objet : RE:  creating a directory-like index
> 
> 
> 
> 
> > I wnat to create a directory like index from a list of names. I want
> to
> > have section heading for each existing first-letter, followed by all
> > names starting with that first letter, omitting 
> non-existant letters.
> > 
> > Like this:
> > 
> > A
> > Alexander
> > Andrea
> > 
> > M
> > Martin
> > Max
> > Moritz
> 
> I can see what you were trying to do... what you need to do is use the
> Muenchian method of grouping - you find the first occurance of each
> group, then apply-templates to its following-siblings (within the
> group).
> 
> This should be what you need:
> 
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:key name="group-by-initial" match="name" use="substring(.,1,1)"/>
> 
> <xsl:template match="root">
>   <div>
>     <xsl:for-each select="name[generate-id(.) =
> generate-id(key('group-by-initial',substring(.,1,1))[1])]">
>       <div 
> style="margin-top:1em;text-transform:uppercase"><xsl:value-of
> select="substring(.,1,1)"/></div>
>       <xsl:apply-templates
> select=".|following-sibling::name[starts-with(.,substring(curr
> ent(),1,1)
> )]">
>         <xsl:sort select="."/>
>       </xsl:apply-templates>
>     </xsl:for-each>
>   </div>
> </xsl:template>
> 
> <xsl:template match="name">
>   <div><xsl:apply-templates/></div>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> cheers
> andrew
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.