Jump to content

Dirk

Members
  • Posts

    1
  • Joined

  • Last visited

Dirk's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hello Readers, as a noob to xpath and xslt i played around with the online xslt at the w3schools website.I added a few lines including a sum to get the amount of all prices. like this: <th><xsl:value-of select='sum(catalog/cd/price)'/></th> It returns an amount of:237.00000000000003 I tried some other values as prices but sometimes i got the right amount sometimes amounts with lots of digits after the dot. Any ideas how to get the right amount ? Thanks, Best RegardsDirk <?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>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> <th>Price</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> <td><xsl:value-of select="price"/></td> </tr> </xsl:for-each> <tr bgcolor="#9acd32"> <th> </th> <th>Summe:</th> <th><xsl:value-of select='sum(catalog/cd/price)'/></th> </tr> </table> </body> </html></xsl:template></xsl:stylesheet>
×
×
  • Create New...