Subject: [xsl] Nested for-each-group From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx> Date: Tue, 28 Sep 2004 11:38:13 +0100 |
Hi all, Given this xml: <tgroup> <col colname="C.HPC" width="17"/> <col colname="C.HPB" width="23"/> <col colname="C.HPA" width="29"/> <col colname="C.I0F" width="17"/> <col colname="C.I0E" width="14"/> <spanspec namest="C.HPC" nameend="C.I0F"/> <spanspec namest="C.HPC" nameend="C.I0E"/> </tgroup> I'm trying to sum the colwidths specified by the spanspecs. I used to use a recursive template, which I'm trying to replace using a nested for-each-group: <xsl:template match="spanspec"> <xsl:variable name="namest" select="@namest"/> <xsl:variable name="nameend" select="@nameend"/> <xsl:for-each-group select="preceding-sibling::col" group-starting-with="*[@colname = $namest]"> <xsl:for-each-group select="current-group()" group-ending-with="*[@colname = $nameend]"> <div><xsl:value-of select="sum(current-group()/@width)"/></div> </xsl:for-each-group> </xsl:for-each-group> </xsl:template> However, this produces: <div>86</div><div>14</div> <div>100</div> I don't understand why I'm getting the "<div>14</div>" output? I know it's part of the outer group, but it shouldn't be part of the inner group. Any ideas why its there? cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to read/create an xsl, Jarno.Elovirta | Thread | RE: [xsl] Nested for-each-group, Michael Kay |
RE: [xsl] How to read/create an xsl, Jarno.Elovirta | Date | [xsl] including a file in xsl, james walker |
Month |