p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   format-number on a string? (http://p2p.wrox.com/showthread.php?t=49672)

dep October 31st, 2006 01:12 PM

format-number on a string?
 
Hello. I have the following line that strips a number out of a string:

<xsl:value-of select="substring-before(substring-after(substring-after(securityKey, ':'), ':'), ':')"/>

I would like to divide this number by 10,000, but it's a string, so I can't. How can I make this a number so I can do math on it?

dep



mhkay October 31st, 2006 01:24 PM

In XSLT 1.0 the conversion will be done automatically, or you can call the number() function.

In XSLT 2.0 you can call the number function. This will give you a double. If you want an integer, you can call the xs:integer() function.

Personally, in 2.0 I would do the string manipulation using a regular expression. I think your expression can be replaced by tokenize(securityKey, ':')[3].

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference


All times are GMT -4. The time now is 07:54 PM.

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