xsl-list
[Top] [All Lists]

RE: String matching without regex

2005-01-31 16:15:22
Wendell Piez <mailto:wapiez(_at_)mulberrytech(_dot_)com> 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.

Regards,
Marcel


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>