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

RE: [xsl] String matching without regex

Subject: RE: [xsl] String matching without regex
From: Marcel Stör <marcel@xxxxxxxxxxxxxx>
Date: Tue, 1 Feb 2005 00:15:22 +0100

Wendell Piez <mailto:wapiez@xxxxxxxxxxxxxxxx> wrote:
> Marcel:
> 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. http://xsltsl.sourceforge.net/
> 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
> translate($string,'#0123456789','-##########')
> 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).

It's not useless at all - very helpful. I knew the code to achieve what I
need would probabely turn out to be very ugly. I didn't expect it to be that
bad, though ;-)
Although I'm knew to XSLT I'll go down that road.


Current Thread