Subject: RE: grouping (was: if or template?) From: Sebastian Rahtz <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 15 May 2000 11:22:34 +0100 (BST) |
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>
</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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: grouping (was: if or template?), G. Ken Holman | Thread | Rendering Engine from XML/XSL into , Bovone Stefano |
How to check if a file exists, Carsten Ullrich | Date | RE: Usage of older XSL version, Ivar Snaaijer |
Month |