|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
how to sum the grand total of the product of two value?
I have a xml file and a xsl file as show in the following, how can i sum the total of the product of the values of "amount" and "cost" ? what wrong with in following xsl, the output is messy .......
<!-- lineItems.xml --> <?xml version='1.0' encoding="ISO8859-1" ?> <?xml-stylesheet type="text/xsl" href="lineItems.xsl" ?> <lineItems> <lineItem> <code>42AC5</code> <title>Loopy Fruit Cereal</title> <amount>12</amount> <cost>4.25</cost> </lineItem> <lineItem> <code>H343A</code> <title>MicroSecond Rice</title> <amount>14</amount> <cost>2.35</cost> </lineItem> <lineItem> <code>EA198</code> <title>Crescent Toothpaste</title> <amount>18</amount> <cost>1.95</cost> </lineItem> </lineItems> <!-- lineItems.xsl --> <?xml version='1.0' encoding="ISO8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:variable name="newLineItems"> <xsl:for-each select="/lineItems/lineItem"> <lineItem> <xsl:copy-of select="*"/> <subTotal><xsl:value-of select="amount*cost"/></subTotal> </lineItem> </xsl:for-each> </xsl:variable> <xsl:variable name="lineItemsTotal"> <xsl:value-of select="sum($newLineItems/subTotal)"/> </xsl:variable> <xsl:value-of select="$lineItemsTotal"/> </xsl:template> </xsl:stylesheet> <!--- the I.E. browser output as followig --> !qlo?y XML }? !qlO(u XSL #j_hj? XML 8eQ0 ?fck/?6q_ c ?etet c?b z_QfN!k0 -------------------------------------------------------------------------------- Sgq?xebSxe 'newLineItems' _UP{?nU0 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > how to sum the grand total of the product of two value? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|