|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: grouping (was: if or template?)
(I wrote this post before finding Steve's example just now from Wednesday
in my archive; I'll still post it since it is what I did this evening for
myself to help me understand what he has developed. I think this is quite
neat!)
At 00/05/08 17:54 +0100, Kay Michael wrote: > I want to then display the Tracker_ID if it is unique followed by all the data for > the specific tracker. This is a truly kewl idea ... but ... isn't the syntax above incorrect? Wouldn't the declaration of the key be as follows? <xsl:key name="tid" match="tracker-id" use="."/> I apologize in advance if this sounds pedantic, but readers might get confused about which attribute is the matching attribute (match=) and which is the selection (use=) since the cited example had it backwards and incorrectly named. I have an example below. I hope this helps. ................... Ken
<xsl:output method="text"/> <!--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-->
<xsl:text> </xsl:text>
<xsl:value-of select="given"/> <!--member distinctions-->
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template></xsl:stylesheet> T:\ftemp>saxon tests.xml tests.xsl Holman Julie Kathryn Ken Ted Mahoney John Margaret
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
|

Cart








