[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: question with using Muenchian/xsl:key (Re: sort/group/count p robl em)
Subject: Re: question with using Muenchian/xsl:key (Re: sort/group/count p robl em) From: David Carlisle <davidc@xxxxxxxxx> Date: Sun, 12 Nov 2000 00:48:24 GMT |
> Thanks for the suggestion, but this did not seems to work. Oh why not? As you replied in this manner I thought I'd try it, it seems to work for me unless I misunderstood the problem. David <x> <itemlist> <item itemid="Z101" units="1"/> <item itemid="Z102" units="2"/> <item itemid="Z101" units="4"/> </itemlist> <itemlist> <item itemid="y101" units="1"/> <item itemid="y102" units="3"/> <item itemid="y102" units="2"/> <item itemid="y101" units="5"/> <item itemid="y101" units="4"/> </itemlist> </x> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:output method="xml" indent="yes"/> <xsl:key name="items-by-itemid" match="item" use="concat(generate-id(..),@itemid)" /> <xsl:template match="itemlist"> <xsl:variable name="x" select="generate-id(.)"/> <xsl:for-each select="item[count(. | key('items-by-itemid', concat($x,@itemid))[1]) = 1]"> <xsl:sort select="@itemid" /> <tr> <td><xsl:value-of select="@itemid"/></td> <td><xsl:value-of select="sum(key('items-by-itemid',concat($x,@itemid))/@units)"/></td> </tr> </xsl:for-each> </xsl:template> </xsl:stylesheet> bash-2.01$ saxon key.xml key.xsl <?xml version="1.0" encoding="utf-8" ?> <tr> <td>Z101</td> <td>5</td> </tr> <tr> <td>Z102</td> <td>2</td> </tr> <tr> <td>y101</td> <td>10</td> </tr> <tr> <td>y102</td> <td>5</td> </tr> _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Control Centre. For further information visit http://www.star.net.uk/stats.asp XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: question with using Muenchian/x, Xiaocun Xu | Thread | RE: question with using Muenchian/x, Kay Michael |
RE: question with using Muenchian/x, Kay Michael | Date | RE: question with using Muenchian/x, Xiaocun Xu |
Month |