I have a xml file like this

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<orders>
<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>
<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>
<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"/>
</order>
</orders>

Now i want to calculate total amount for each order

this is my xsl file

<xsl:for-each select="/orders/order">
                        <tr>
                            <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>
                        </tr>                        
                    </xsl:for-each>

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.