[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Building menus
Hi > I would like to build a menu that sorts the entrys by first character, and > only display that character once even if several entrys begins with that > character. > > Like this: [A]-[B]-[F]-[I] > > I have tryed to match the first character whith proceding-siblings first > character, but i can't get it to work. This uses keys for it, but it might be waste of time if you don't have that many entries. You probably want HTML, hope this will help you with that. [c:\temp]type menu.xml <?xml version="1.0" encoding="ISO-8859-1"?> <root> <entry name="Flls"> <fo>lsfjlksdsdfjlsjfsf</fo> </entry> <entry name="Ajjf"/> <entry name="Bjjjdjj"/> <entry name="Ilsjdf"/> <entry name="Ajjjjj"/> </root> [c:\temp]type menu.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:key name="letter" match="/root/entry" use="substring(@name,1,1)"/> <xsl:template match="root"> <xsl:apply-templates select="entry[generate-id(.) = generate-id(key('letter', substring(@name,1,1)))]"> <xsl:sort select="@name" /> </xsl:apply-templates> </xsl:template> <xsl:template match="entry"> <xsl:text>[</xsl:text> <xsl:value-of select="substring(@name,1,1)" /> <xsl:text>]</xsl:text> <xsl:if test="not(position() = last())"> <xsl:text>-</xsl:text> </xsl:if> </xsl:template> </xsl:stylesheet> [c:\temp]saxon menu.xml menu.xsl [A]-[B]-[F]-[I] -- Jarno Elovirta jarno.elovirta@xxxxxxxxxxxxxx CODEONLINE Ltd. http://www.codeonline.com P.O. Box 538 (Ukonvaaja 2 A), FIN-02130 Espoo, Finland Mobile: +358 40 772 6785 Fax: +358 9 4393 0410 "Hoc non credo; toga mea surrepta est iterum!" XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|