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

RE: grouping (was: if or template?)

Subject: RE: grouping (was: if or template?)
From: Sebastian Rahtz <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 May 2000 11:22:34 +0100 (BST)
sebastian root name
G. Ken Holman writes:
 >              <!--prepare to examine all names valued by surname-->
 > <xsl:key name="surnames" match="name" use="surname"/>
 > 
 > <xsl:template match="/">                         <!--root rule-->
 >              <!--select only those name elements whose unique
 >                  generated id is equal to the generated id of the
 >                  first of the key members with the same surname-->
 >    <xsl:for-each
 >          select="//name[generate-id(.)=
 >                         generate-id(key('surnames',surname)[1])]">
 >      <xsl:value-of select="surname"/>     <!--show the grouping-->
 >      <xsl:text>&#xd;&#xa;</xsl:text>
 >                          <!--select only those for the grouping-->
 >      <xsl:for-each select="//name[surname=current()/surname]">
 >        <xsl:sort select="given"/>    <!--sorted within grouping-->

you can speed this up again, I believe, by using the key again

     <xsl:for-each
           select="//name[generate-id(.)=
                         generate-id(key('surnames',surname)[1])]">
     <xsl:variable name="surname" select="surname"/>
     <xsl:for-each select="key('surnames',$surname)">

 ...

that is to say, for every unique surname, consult the key again to
get the list of people with that surname. that way, you do not have to 
navigate the tree again at all, since the list of relevant nodes is
already known.

Sebastian


 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.