Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2004, 08:01 PM
Registered User
 
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Performing Division in XSLT... Please help..

Hi,

I am trying to do the following:

divide the value of an element, by the value of a parameter.
The paramater (size) is passed to the template from an <xsl:call-template>
It returns me only NaN...
Any ideas?

Here is the snippet:

<xsl:for-each select = "/A//B">
 <tr>
  <td><b>Percentage:</b></td>
  <td><b><xsl:value-of select="number('C[@name="aaa"') div number ($size) * 100"/></b></td>
  </tr>
</xsl:for-each>

It seems that the number() function cannot extrace the value of the element...
Any help will be appreciated!

Thanks,

Kiril.
 
Old May 16th, 2004, 08:22 PM
Authorized User
 
Join Date: Oct 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like you have a syntax error in your value-of statement:

>>
<xsl:value-of select="number('C[@name="aaa"') div number ($size) * 100"/>
<<

try:

<xsl:value-of select="number(C[@name="aaa"]) div number ($size) * 100"/>

If this doesn't work, we'll have to see a snippet of what the node "C" with the @name attribute typically contains...

cheers,

...sam


 
Old May 16th, 2004, 08:36 PM
Authorized User
 
Join Date: Oct 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry,

syntax error in my correction :(

try this:

<xsl:value-of select="number(C[@name='aaa']) div number ($size) * 100"/>

...sam

 
Old May 17th, 2004, 05:27 AM
Registered User
 
Join Date: May 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Sam.. Actually the problems was with the data - thanks for the note above - there was a text string after the number..
This works:
<xsl:value-of select="substring(number(substring-before(Action[@name='Database Size'], ' Mb')) div number($size) * 100, 1,5)"

Thanks again!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Division by zero Corey BOOK: Beginning Access 2003 VBA 2 April 13th, 2007 02:56 PM
Division by zero error Corey Access 4 October 20th, 2005 12:51 PM
division by zero rickjg JSP Basics 1 November 9th, 2004 08:03 AM
Division by zero error ss2003 Beginning PHP 5 January 1st, 2004 11:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.