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 July 25th, 2013, 02:29 AM
Registered User
 
Join Date: Jul 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to find a particular string in a sequence of many strings using xsl1.0

I have the following string:

string = 'http://aaa/bbb/ccc/ddd/eee/fff/ggggg'

From the above string i need the string 'ddd' alone in a variable. How can we make use of XSLT 1.0 string function to get 'ddd' string alone?
 
Old July 25th, 2013, 03:18 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You need to say what it is that makes the string 'ddd' recognizable. For example, do you want the third component of the URI path, or the last-but-two component, or the one that follows 'ccc', or the one that is equal to 'ddd'?

Giving one example of an input and output does not constitute a specification.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old July 25th, 2013, 03:31 AM
Registered User
 
Join Date: Jul 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Let me put in this way,
string = 'http://aaa/bbb/ccc/ddd/eee/fff/ggggg'

in the above string , i want the fourth component 'ddd' of the url. How do i extract 'ddd' alone.

Or, i want the string between the 5th occurence of '/' and 6th occurence of '/'
 
Old July 25th, 2013, 03:44 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

substring-after($x, '//') gives you the string after the '//', so

substring-after(substring-after($x,'//'), '/') gives you the content starting with 'bbb'.

Apply that a couple more times and you get the content starting with 'ddd'.

Then substring-before(..., '/') applied to that result truncates the string at the next '/'.

Cumbersome, yes. So move to XSLT 2.0 if you can.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting strings and string.format eightbits2011 BOOK: Visual Basic 2008 Programmer's Reference ISBN: 978-0-470-18262-8 7 July 31st, 2011 10:40 PM
how to find a string in another string in vb6 satish_k VB How-To 3 March 30th, 2007 12:17 PM
Retrieving strings in sequence lowell VB.NET 1 March 8th, 2007 06:31 PM
syntax to find a string in a string cole SQL Server 2000 2 October 10th, 2005 06:06 PM
RegExp looping for multiple strings in string interrupt Javascript How-To 2 June 20th, 2005 05:37 AM





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