[XSLT] Summing calculated values

Here should go questions about transforming XML with XSLT and FOP.
Worteltaart
Posts: 2
Joined: Sat Nov 03, 2007 10:55 am

[XSLT] Summing calculated values

Post by Worteltaart »

Hi,
Say I have this order/orderline/article structure in my application.
Each orderline:

Code: Select all


<orderline articleidref="article0003">
<quan>1</quan>
</orderline>
The price is fetched from the article, all an all in a pretty BLOATED function I've tried to add up the calculated values for each order line:

Code: Select all


<xsl:template name="total">
<xsl:param name="orderid_ref">0</xsl:param>
<xsl:variable name="tmp_subprice">

<!-- loop throuch all orderlines -->
<xsl:for-each select="/webshop/orders/order[@orderid=$orderid_ref]/orderregels/orderregel" >

<!-- remember quantity of current orderline -->
<xsl:variable name="tmp_artikelaantal" select="aantal" />

<!-- remember articleid from current line -->
<xsl:variable name="tmp_artikelid" select="@artikelidref" />

<!-- remember price from current article -->
<xsl:variable name="tmp_artikelprijs" select="number(translate(substring(/webshop/artikelen/artikel[@artikelid=$tmp_artikelid]/prijs, 3), ',', '.'))" />

<!-- calculate value of single orderline -->
<xsl:value-of select="$tmp_artikelaantal * $tmp_artikelprijs" />


</xsl:for-each>
</xsl:variable>

<xsl:value-of select="$tmp_subprice" />

</xsl:template>
This nicelt prints the value for each of the orderlines in an order, but how do I go about summing these values, I'm totally lost here. Any help is appreciated![/code]
Worteltaart
Posts: 2
Joined: Sat Nov 03, 2007 10:55 am

Post by Worteltaart »

I have resolved this is issue by using the count() method.
Post Reply