XSL Calculation

Discussion in 'General Computer Support' started by JohnM, May 6, 2012.

  1. JohnM

    JohnM

    Joined:
    May 6, 2012
    Messages:
    2
    Location:
    London
    Hello everybody! Id like some help,i dont know how to calculate the total prize and the total items sold.There are 10 prizes and 10 items to be calculated.


    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
    <html>
    <body>
    <h2>Furniture</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th>Name</th>
    <th>Address</th>
    <th>Telephone number</th>
    <th>Ordered_item</th>
    <th>Start</th>
    <th>Prize</th>
    </tr>
    <xsl:for-each select="Customers/Customer">
    <tr>
    <td><xsl:value-of select="Name"/></td>
    <td><xsl:value-of select="Address"/></td>
    <td><xsl:value-of select="Telephone_number"/></td>
    <td><xsl:value-of select="Ordered_item"/></td>
    <td><xsl:value-of select="start"/></td>
    <td><xsl:value-of select="prize"/></td>
    </tr>
    </xsl:for-each>

    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    I used that format:
    <P>
    <xsl:value-of select="//prize[1]"/>
    <xsl:text> + </xsl:text>
    <xsl:value-of select="//prize[2]"/>
    <xsl:text> = </xsl:text>
    <xsl:value-of select="//prize[1] + //prize[2]"/>
    </P>

    till "//prize[10]" but it only displays : 400+=NaN

    The XML file:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Customers>
    <Customer>
    <Name>John </Name>
    <Address>19 Holloway Road </Address>
    <Telephone_number>07827384928 </Telephone_number>
    <Ordered_item>Sofa </Ordered_item>
    <start>2012-02-20</start>
    <prize>400</prize>
    </Customer>

    <Customer>
    <Name>Nick</Name>
    <Address>30 Holloway Road </Address>
    <Telephone_number>09382930492 </Telephone_number>
    <Ordered_item>Table</Ordered_item>
    <start>2012-03-10</start>
    <prize>200</prize>
    </Customer>

    <Customer>
    <Name>Roger</Name>
    <Address>13 Holloway Road </Address>
    <Telephone_number>07823049828 </Telephone_number>
    <Ordered_item>Bedside Cabinet </Ordered_item>
    <start>2012-01-14</start>
    <prize>100</prize>
    </Customer>

    <Customer>
    <Name>Duncan</Name>
    <Address>92 Holloway Road </Address>
    <Telephone_number>07839482712</Telephone_number>
    <Ordered_item>Sofa </Ordered_item>
    <start>2012-04-23</start>
    <prize>450</prize>
    </Customer>

    <Customer>
    <Name>Chris </Name>
    <Address>123 Holloway Road </Address>
    <Telephone_number>072839402912 </Telephone_number>
    <Ordered_item>Mattresses </Ordered_item>
    <start>2012-02-22</start>
    <prize>120</prize>
    </Customer>

    <Customer>
    <Name>Matt</Name>
    <Address>87 Holloway Road </Address>
    <Telephone_number>072839402945 </Telephone_number>
    <Ordered_item>Table </Ordered_item>
    <start>2012-03-07</start>
    <prize>98</prize>
    </Customer>

    <Customer>
    <Name>Jake </Name>
    <Address>72 Holloway Road </Address>
    <Telephone_number>07263849271 </Telephone_number>
    <Ordered_item>Bedside Cabinets </Ordered_item>
    <start>2012-03-02</start>
    <prize>25</prize>
    </Customer>

    <Customer>
    <Name>Amy </Name>
    <Address>69 Holloway Road </Address>
    <Telephone_number>07877306301 </Telephone_number>
    <Ordered_item>Table </Ordered_item>
    <start>2012-03-29</start>
    <prize>95</prize>
    </Customer>

    <Customer>
    <Name>Francesca</Name>
    <Address>90 Holloway Road </Address>
    <Telephone_number>0772732348 </Telephone_number>
    <Ordered_item>Mattresses </Ordered_item>
    <start>2012-01-09</start>
    <prize>150</prize>
    </Customer>

    <Customer>
    <Name>Ryann </Name>
    <Address>174 Holloway Road </Address>
    <Telephone_number>078290375019</Telephone_number>
    <Ordered_item>Sofa </Ordered_item>
    <start>2012-04-22</start>
    <prize>700</prize>
    </Customer>

    </Customers>

    Thank you in advance!
     
    Last edited: May 6, 2012
    JohnM, May 6, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tintrung

    how to sum in XSL

    tintrung, Nov 13, 2006, in forum: Software
    Replies:
    0
    Views:
    602
    tintrung
    Nov 13, 2006
  2. richasharma
    Replies:
    0
    Views:
    953
    richasharma
    Dec 26, 2007
  3. univbgp102@gmail.com
    Replies:
    1
    Views:
    410
    gnu / linux
    May 22, 2008
  4. univbgp102@gmail.com
    Replies:
    0
    Views:
    530
    univbgp102@gmail.com
    May 20, 2008
  5. Dhanabal
    Replies:
    0
    Views:
    383
    Dhanabal
    May 28, 2008
Loading...

Share This Page