[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 18:14:45 -0500
xslt string index
Hi Michael,


> You don't need substring() to implement index-of(). To expand DC's
response,
> here it is:

I don't think I was clear in my warning.  The original poster wanted
an index-of() to
do the below (from his original post):

>Want to do something like this...
>substring($titleText,
>indexOf($titleText, ' findThisTextsIndex ')+5 ,
>indexOf($titleText, 'toHere') )

I was just pointing out that he might get unexpected results if he
created a function and used it in the manner he originally posted,
without accounting for the fact that call to substring would be wrong
since the third argument of substring is length, not index of the
start of the terminating pattern.

That's why I mentioned difference (haven't done a lot of function
building in XSLT 2.0 so you'll just have to accept the pesuedo-code.
Sorry, but I'm planning on playing around more whenever I get another
free weekend).

If you have the function eg:index-of, you'll still need the second
that takes in the third argument as the index-of the string instead of
the length.  Ie if this was some method

substring-using-indexes(string,start_index,end_index) {
return substring(string,start_index, end_index - start_index);
}

or something along those lines (might have a off by one here, trying
to cook dinner and answer email at the same time ;) ).

Jon Gorman

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.