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

RE: Building menus

Subject: RE: Building menus
From: "Jarno Elovirta" <jarno@xxxxxxxxxxxxxx>
Date: Mon, 31 Jul 2000 13:14:41 +0300
html 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


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.