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 March 18th, 2007, 01:26 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default Testing a string for digits

Hi All,

Is this the correct code to test a string for digits?

<xsl:when test="contains(current-grouping-key(), '[0-9]')"/>

Thanks,


 
Old March 18th, 2007, 02:03 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

To test whether the string consists entirely of digits, use

matches($in, '^[0-9]*$')

or perhaps more simply

($in castable as xs:integer)

To test whether it contains at least one digit, use

matches($in, '[0-9]')

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 18th, 2007, 02:48 PM
Friend of Wrox
 
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

As always... Thank you very much

perfect







Similar Threads
Thread Thread Starter Forum Replies Last Post
testing locally but using remote connection string JezHarvey BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 August 12th, 2008 07:28 AM
Mulitplication of two digits in Datagrid [email protected] Visual Studio 2005 0 June 10th, 2008 03:35 PM
Testing a String gabster XSLT 2 August 15th, 2007 12:13 PM
Restricting the # of digits after a decimal in a K stevenyoo321 VB How-To 1 April 18th, 2007 07:52 AM
Number of Digits Colonel Angus Javascript How-To 3 December 1st, 2004 09:12 AM





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