| | |
XPath Expression to calculate total amount for order details
Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
I have a xml file like this
Now i want to calculate total amount for each order
this is my xsl file
When i transform xml+xsl => html, an error occured at the line
I can only guess that my xpath - expression is not correct, i also tried this:
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
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<?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
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<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
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<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:
XML, XSLT and XPATH Syntax (Toggle Plain Text)
<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
Last edited by extkml; 20 Days Ago at 6:29 am.
![]() |
Similar Threads
- logarithmic expression how to calculate?? Please help (Shell Scripting)
- total amount (ASP.NET)
- display total amount (VB.NET)
- Simple program (newbie!) doesn't work. (C++)
- Calculate total charges (C++)
- How to calculate total free memory (C)
- VB and Excel. (Visual Basic 4 / 5 / 6)
- How to calculate total days? (VB.NET)
Other Threads in the XML, XSLT and XPATH Forum
- Previous Thread: Convert XML file to another XML file using XSLT
- Next Thread: XML
| Thread Tools | Search this Thread |
api blogger blogging code delete development dynamiccreationofnvariablesinxslt error firstthreecharacterofastringrequired flipbook gdata google html include java link linspire linux microsoft news node openoffice overwrite precedence programming rss standards swf template transform variable w3c web xml xmlnotloading xmlonserver xsl xslt






