XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 3rd, 2003, 10:17 AM
r390gt1 r390gt1 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 1 r390gt1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > how to sum the grand total of the product of two value?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway