[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Re: Multiple Level Grouping
Subject: [xsl] Re: Multiple Level Grouping From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 26 Sep 2002 20:32:37 +0100 |
Hi Charles, > The first grouping is working fine. I then get to the second > grouping which uses a combined key with the concat command. When I > display the generate-id() values or the value of > "$vPhase[generate-id() = generate-id(key('key2', concat(STRPHASE,' > ',STRBUILDING))[1])]" it looks like I am capturing a unique value. > However, the actual results is the same node being repeated. What I > don't understand is why the for-each processes this multiple times > rather than once. You're doing: For each unique COLUMN (by STRPHASE, and sorted by STRPHASE), create a row: > <xsl:for-each select="COLUMN[count(. | key('key1', > STRPHASE)[1]) = 1]"> > <xsl:sort select="STRPHASE"/> > <tr><td class="ReportCellGroup" > colspan="5"><xsl:value-of select="STRPHASE"/></td></tr> Then for each COLUMN with that STRPHRASE: > <xsl:for-each select="key('key1', STRPHASE)"> create a variable holding COLUMNs with that STRPHRASE: > <xsl:variable name="vPhase" > select="key('key1', STRPHASE)" /> and for each COLUMN with that STRPHRASE and a unique STRBUILDING create another row: > <xsl:for-each select="$vPhase[generate-id() > = generate-id(key('key2', concat(STRPHASE,' ',STRBUILDING))[1])]"> > <tr><td class="ReportCellGroup" > colspan="4"><xsl:value-of select="STRBUILDING"/></td></tr> before going on to iterate through all the COLUMNs with the same STRPHRASE and STRBUILDING: > <xsl:for-each select="key('key2', > concat(STRPHASE,' ',STRBUILDING))"> > <tr> > <td></td><td></td> The trouble is that you're iterating *twice* through the COLUMNs -- for *every* COLUMN, you're iterating through *every* COLUMN that's unique by STRPHRASE and STRBUILDING. You need to cut out the intermediate xsl:for-each, to give: <xsl:for-each select="COLUMN[count(. | key('key1', STRPHASE)[1]) = 1]"> <xsl:sort select="STRPHASE"/> <tr> <td class="ReportCellGroup" colspan="5"> <xsl:value-of select="STRPHASE"/> </td> </tr> <xsl:variable name="vPhase" select="key('key1', STRPHASE)" /> <xsl:for-each select="$vPhase[generate-id() = generate-id(key('key2', concat(STRPHASE,' ',STRBUILDING))[1])]"> <tr> <td class="ReportCellGroup" colspan="4"> <xsl:value-of select="STRBUILDING"/> </td> </tr> <xsl:for-each select="key('key2', concat(STRPHASE,' ',STRBUILDING))"> <tr> ... </tr> </xsl:for-each> </xsl:for-each> </xsl:for-each> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re: Re: Selecting a rando, Martin Lormes | Thread | [xsl] Re: Re: Re: Selecting a rando, Dimitre Novatchev |
Re: [xsl] Re: Re: Selecting a rando, Martin Lormes | Date | [xsl] Re: Re: Re: Selecting a rando, Dimitre Novatchev |
Month |