[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Testing if a string begins with numeric in XSL 1.0

Subject: RE: Testing if a string begins with numeric in XSL 1.0
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 20 Oct 2009 09:33:58 +0100
RE:  Testing if a string begins with numeric in XSL 1.0
Try test="translate(substring($in,1,1), '0123456789', '') = ''"

(it may need refining as it also gives true if $in is zero-length).


Michael Kay

> -----Original Message-----
> From: Adrian Stringer [mailto:adrian.stringer@xxxxxxxxxxxx] 
> Sent: 20 October 2009 09:29
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Testing if a string begins with numeric in XSL 1.0
> Hi,
> Is this the correct/best way to test whether a string begins 
> with a digit in XSL 1.0?
>     <xsl:when test="string(number(substring($input-name, 1, 
> 1))) != 'NaN'">
> I guess using a regular expression in XSL 2.0 would be the 
> best approach, but unfortunately I'm constrained to using 
> MSXSL and hence XSL 1.0 at the moment.
> Thanks,
> Ade
> --
> Adrian Stringer
> Software Developer
> Direct Dial: 0845 265 6029
> Mobile:
> Motors.co.uk Ltd is registered in England and Wales with 
> Company No. 5975777.  VAT registration GB 243 5711 74 
> Registered address: Northcliffe House, 2 Derry Street, London 
> W8 5TT.  Motors.co.uk Ltd is a Daily Mail and General Trust 
> plc company.
> This message and any attachments are intended for the named 
> addressee only. It contains information which may be 
> confidential, legally privileged or otherwise protected by 
> law.  If you are not the intended recipient, please telephone 
> or email the sender and delete this message and any 
> attachments from your system.  If you are not the intended 
> recipient you must not copy this message or attachments or 
> disclose the contents to any other person. Emails are not 
> secure and may contain viruses. Motors.co.uk reserves the 
> right to monitor all e-mail communications.

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.