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

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

Subject: Re: is there a String indexOf() function in Xpath?
From: Jon Gorman <jonathan.gorman@xxxxxxxxx>
Date: Thu, 28 Jul 2005 14:48:54 -0500
indexof 1
> 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

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.