Re: [xsl] is there a String indexOf() function in Xpath?

Subject: Re: [xsl] is there a String indexOf() function in Xpath?
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Thu, 28 Jul 2005 14:48:54 -0500
> Want to do something like this...
> substring($titleText,
> indexOf($titleText, ' findThisTextsIndex ')+5 ,
> indexOf($titleText, 'toHere') )
>

An index of function would be nice, but it's not clear it's needed.
Perhaps a description of your problem would be more helpful then what
you are trying to do.  In any case, I'll give it a stab below.


Why not just do some combination of substring, substring-before and
substring-after?

I'm going to create an entirely fictional example

I have some string of characters that contain two indicators of a
special sequence of text, START and END.  In addition, there are
always five characters after START that are always the same.  (It may
be you're using the +5 to try to avoid the starting characters, but
who knows since you didn't give us that information.)

Example string:  It was a dark and stormy night START00123Needs a
little more punch, how about it was a very, very dark and very, very
stormy nightEND which would be the night of a most...

substring-after(TheString,"START")

gives us everything after START ie

00123Needs a little more punch, how about it was a very, very dark and
very, very stormy nightEND which would be the night of a most...


substring(substring-after(TheString,"START"),6)
gives us the string starting with the 6th character after START

Needs a little more punch, how about it was a very, very dark and
very, very stormy nightEND which would be the night of a most...



substring-before(substring(substring-after(TheString,"START"),6),"END")
gives us the string starting with the 6th charcter after START but before END

Needs a little more punch, how about it was a very, very dark and
very, very stormy night


Is that something like what you're looking for?



Jon Gorman
ps.  Feels like I'm abusing substring-after and substring-before
lately and it's been a while since I've even used them in my own code.

Current Thread