I have a xml file like this

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<order orderDate="1/1/2009" orderNo="1">
<customer id="nnghiem" name="nguyen nghiem"/>
<item id="item-1" price="25000" quantity="0"/>
<item id="item-2" price="22000" quantity="3"/>
<order orderDate="2/2/2009" orderNo="2">
<customer id="lp" name="lampard"/>
<item id="item-1" price="25000" quantity="2"/>
<item id="item-2" price="22000" quantity="8"/>
<order orderDate="3/3/2007" orderNo="3">
<customer id="nnghiem" name="nguyen nghiem"/>
<item id="item-1" price="25000" quantity="7"/>
<item id="item-2" price="22000" quantity="6"/>

Now i want to calculate total amount for each order

this is my xsl file

<xsl:for-each select="/orders/order">
                            <td> <xsl:value-of select="@orderNo"></xsl:value-of> </td>
                            <td> <xsl:value-of select="@orderDate"></xsl:value-of> </td>
                            <td> <xsl:value-of select="customer/@name"></xsl:value-of> </td>
				    <td> <xsl:value-of select="sum(item/@quantity * item/@price)"></xsl:value-of></td>

When i transform xml+xsl => html, an error occured at the line

<xsl:value-of select="sum(item/@quantity * item/@price)"></xsl:value-of>

I can only guess that my xpath - expression is not correct, i also tried this:

<xsl:value-of select="sum(item/@quantity * @price)"></xsl:value-of>

But i also got the same problem. How can i fix this?

I need some advices, i've just learnt XSL for 1 week.

Thanks for your attention

Edited by extkml: n/a

7 Years
Discussion Span
Last Post by __avd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.