Jump to content

XSL Total variable


mjs87

Recommended Posts

Hi, I am fairly new to XML/XSL. I am trying to sum a variable that is within a for-each loop. The $subtotal variable is working out the total price for each product ordered on a invoice. Once all the products have been output I need to calculate the overall total price. I have tried to create a variable and increment it on each loop but you cannot change a variable once it has been set from what I have read. below just shows where I have just tried to sum the $subtotal variable...any ideas would be appreciated...thanks in advance

 

<xsl:for-each select="DeliveryDetails/ProductOrder">
<tr align="center">
  <td width="150"><xsl:value-of select="Description" /></td>
   <td width="150"><xsl:value-of select="ReferenceNo" /></td>
  <td width="100"><xsl:value-of select="Quantity" /></td>
  <td width="100">£<xsl:value-of select="Price" /></td>
  <td width="100">£  <xsl:variable name="subtotal" select="Quantity*Price" /><xsl:value-of select="$subtotal" /></td>
</tr>
  </xsl:for-each>

<xsl:value-of select="sum($subtotal)"/>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.