Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2007, 02:20 PM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default last instance of char -> w/out using recursion

Is there a way to find the last instance of a character in a string without using recursion? I have a recursive solution, but it is exceptionally slow.. Thanks

 
Old September 19th, 2007, 05:43 PM
Authorized User
 
Join Date: Nov 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to jkmyoung
Default

If you're using XSLT 2.0, you could use the tokenize function.
Then take the length of the last string, and subtract it from the total length.

This functions runs fairly slowly, but will probably not have the overhead of the recursive templates.

If that's not an option, you could divide the string in 2 and search the last half first, then the first half; (this is another recursive template).

 
Old September 20th, 2007, 02:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't think a non-recursive solution is possible in 1.0. But some recursive solutions (and some XSLT processors!) may be faster than others. Show us your code.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 20th, 2007, 11:09 AM
Authorized User
 
Join Date: Feb 2007
Posts: 51
Thanks: 3
Thanked 0 Times in 0 Posts
Default

thanks for response guys. I have to use XSLT 1.0. I think I will simply muddle through with current recursion scheme. I have plenty of other things to do while I wait for it to crank through the transformation!

 
Old September 20th, 2007, 12:20 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There may well be a faster way of writing the code, but first you have to show us your code.

Please don't be shy of doing this. Exposing your code and getting feedback on it is a great way of learning.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
Invalid conversion from 'char*' to 'char' deuxmio C++ Programming 3 December 8th, 2006 07:56 AM
Recursion lincsimp XSLT 1 August 16th, 2005 04:26 PM
Recursion shan9 JSP Basics 0 November 17th, 2004 09:29 PM
recursion nulogix PHP How-To 1 June 28th, 2004 03:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.