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

RE: Xslt 2 stripping out non-numbers

Subject: RE: Xslt 2 stripping out non-numbers
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Tue, 19 Apr 2005 13:49:46 -0400
java replaceall
correction: the regex should be something like: [^0-9].

Douglas Ross
Developer, HTML UI Framework
Kronos
www.kronos.com


-----Original Message-----
From: Ross, Douglas [mailto:DRoss@xxxxxxxxxx]
Sent: Tuesday, April 19, 2005 1:26 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Xslt 2 stripping out non-numbers

I use the java hook to call the replaceAll method on the String object.
Then I pass in reg ex to remove unwanted text:

declare namespace:
	xmlns:java="java:java.lang.String"

then use replaceAll method:

<xsl:variable name="clean" select="java:replaceAll(string($input),
'[0-9]', '')" />

There may be an easier (non java function) way but this works in Saxon
and Xalan. Note the namespaces may differ.

Douglas Ross
Developer, HTML UI Framework
Kronos
www.kronos.com


-----Original Message-----
From: Jim Neff [mailto:jneff@xxxxxxxxxxxxxxx]
Sent: Tuesday, April 19, 2005 1:23 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Xslt 2 stripping out non-numbers

Greetings,

I need to strip out non-numerical values from a string.

Here is a sample input value:  TUV0062

And what I want is :  0062  (or just 62)

Here's what I've tried so far:

for $i in tokenize(state_license_number, '\.') return xs:string( if
(string(number(.)) = 'NaN') then '' else $i)

But this does not work.  I get an empty string as a result

If I do this:

for $i in tokenize(state_license_number, '\.') return xs:string($i)

I get the whole string back so I know my "for" statement is returning
something.

What is the correct way to do this using XSLT 2?

Thanks,
Jim

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.