Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Math and xsl, pt.2 Math and xsl, pt.2To: NULL Date: 6/2/2005 4:53:00 PM Hi,
In my books.xml file, each book has a price node that contains other
nodes. It looks like this:
<books>
<book>
<title>Some Title</title>
<author>One Author</author>
<author>Another Author</author>
<listprice>
<amount>1726</amount>
<formattedprice>$17.26</formattedprice>
</listprice>
<ourprice>
<amount>1531</amount>
<formattedprice>$15.31</formattedprice>
</ourprice>
</book>
<!-- other book nodes go here -->
</books>
This is what I've done:
<xsl:value-of select="substring(books/book/listprice/formattedprice, 2)
- substring(books/book/ourprice/formattedprice, 2)"/>
Now, this works fine, but it creates a new problem for me. For some
books I get savings that aren't rounded. For example, using xsl, the
html output looks like this (I know its boring - shame on me :-( ):
Title = 1776
ListPrice = 32.00
OurPrice = 21.12
Savings = 10.8799999999999999
Savings simply takes the result of (ListPrice minus OurPrice) and
divides it by the ListPrice.
Is there any way to round the savings data to the nearest hundredth
using xsl or xpath?
Thanks,
Roshawn
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
