[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: grouping (was: if or template?)
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
|
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
|