[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] String matching without regex

Subject: Re: [xsl] String matching without regex
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 31 Jan 2005 17:22:40 -0500


At 07:11 AM 1/31/2005, Jon wrote:
I am a newbie as well, but have found some good tools from the XSLT
Standard Library.

I'm not a newbie, and I think this is an excellent answer.

Marcel, look at this, and also take a look at resources such as the XSL FAQ on strings, Sal Mangano's "XSLT Cookbook" (O'Reilly), maybe Jeni Tennison's "XSLT On the Edge".

The reason your question is hard to answer is that the kind of processing you are asking about is somewhat outside what XSLT 1.0 is designed to do ("introspecting" into string values, not simply driving behavior from markup), and therefore involves a fair amount of what Tommie (the list owner) describes as "scratching your ear with your elbow". It's not impossible: you can use a combination of translate(), string-length(), string-before() and contains() to do it. But it's not pretty either.

For example: to express "'.' followed by two digits" you first have to do something like


to turn strings like "here's a #6 and a currency value $99.99" into "here's a -# and a currency value $##.##" -- then you can use contains() or substring($newstring, string-length($newstring - 3)) to find out if ".##" is in it, or ends it -- because XSLT 1.0 has no notion of what's a digit.

It's all a little much to ask someone to write for free: a bit pesky, yet not terribly interesting either. But no one wants to give an unhelpful answer (so we don't).

I hope that isn't totally useless. Check out the online resources: this kind of thing *has* been done before (and I've just given you some tips, despite myself).


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread