Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Math and xsl, pt.2

From: Roshawn Dawson <udrago@---------.--->
To: 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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent