[xsl] using preceding-sibling to display subtotal row

Subject: [xsl] using preceding-sibling to display subtotal row
From: dmitrik@xxxxxxxxxxxxxx
Date: Fri, 7 Jan 2005 10:14:40 -0500 (GMT-05:00)
There are a list of elements, and the following code is trying to create a new row to display subtotals.
There might be any number of Customer rows. Is there a way to check if I've reached the last customer, and then
insert the subtotal row? The following code is inserting on every row, instead of the last.

Thanks,
Dmitri

<xsl:for-each select="../Trade[Customer = current()/Customer]">

<xsl:choose>
	  
	  <!-- <xsl:when test="preceding-sibling::Trade[1]/Customer = Customer">-->
	  <xsl:when test="preceding-sibling::Trade[Customer = current()/Customer]/Customer = Customer">
	
		


	   
	   </xsl:when>
	    <xsl:otherwise>
	
	<tr>
	
	<!--<td><b><xsl:value-of select="Customer"/></b></td>-->
	<td></td>
	<td></td>
	<td align="right"><b><xsl:value-of select="format-number(sum(../Trade[Customer = current()/Customer]/Step[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))&gt;=
	concat(substring($global,7),substring($global,1,2),substring($global,4,2))]
	   [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))&lt;
	concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))]/StepCharge)+sum(../Trade[Customer = current()/Customer]/Step[concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))&gt;=
	concat(substring($global,7),substring($global,1,2),substring($global,4,2))]
	   [concat(substring(MinFlowDate,7),substring(MinFlowDate,1,2),substring(MinFlowDate,4,2))&lt;
	concat(substring($global,7)+3,substring($global,1,2),substring($global,4,2))]/StepSetoff), '###,###,###,##0')"/></b></td>
	
	</tr>   

	    </xsl:otherwise>
	    </xsl:choose>

</xsl:for-each>

Current Thread