473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Iterating through a substring

Hi,

I am using XPath and XSLT and I have a string containing something like
this:

"gbahes75\Projects\AddressService\Datapool\EnterAd dress.sdd"

I want to get'EnterAddress.sdd', and I am using the function
'substring-after'

(note:
MESSAGE_TEXT="gbahes75\Projects\AddressService\Dat apool\EnterAddress.sdd")

substring-after(MESSAGE_TEXT,'\')

But I am unsure on how to get the value after the *last* '\'

Thanks

Aidy

Apr 6 '06 #1
2 1384


aidy wrote:
But I am unsure on how to get the value after the *last* '\'


You were already told to write a recursive named template to which you
pass the whole string as a parameter and then apply e.g. substring-after
until you have found the last part.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 6 '06 #2
aidy wrote:
"gbahes75\Projects\AddressService\Datapool\EnterAd dress.sdd"

I want to get'EnterAddress.sdd', and I am using the function
'substring-after'


Quite easy, but you need to use recursion
<xsl:template name="str-path-2-filename" xml:space="default" >
<xsl:param name="path" select="/.." />

<xsl:param name="left-path" select="substring-after ($path, '/')" />

<xsl:choose >
<xsl:when test="$left-path != '' " >
<xsl:call-template name="str-path-2-filename" >
<xsl:with-param name="path" select="$left-path" />
</xsl:call-template>
</xsl:when>

<xsl:otherwise ><xsl:value-of select="$path" /></xsl:otherwise>
</xsl:choose>
</xsl:template>

Apr 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Radhika Sambamurti | last post by:
Hi, I've written a substring function. The prototype is: int substr(char s1, char s2) Returns 1 if s2 is a substring of s1, else it returns 0. I have written this program, but Im sure there is an...
7
by: Dave Hansen | last post by:
OK, first, I don't often have the time to read this group, so apologies if this is a FAQ, though I couldn't find anything at python.org. Second, this isn't my code. I wouldn't do this. But a...
1
by: bdwise | last post by:
I have a hash table with key/value like this: aaaa 1 aa 2 bbbb 3 I am iterating over a datatable and trying to search and replace values in it based on a match in the hashtable. ...
6
by: Gustaf Liljegren | last post by:
I ran into this problem today: I got an array with Account objects. I need to iterate through this array to supplement the accounts in the array with more data. But the compiler complains when I...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
5
by: btober | last post by:
I can't seem to get right the regular expression for parsing data like these four sample rows (names and addresses changed to ficticious values) from a text-type column: Yolanda Harris, 38, of...
11
by: dyc | last post by:
how do i make use of substring method in order to extract the specified data from a a long string? I also need to do some checking b4 extracting the data, for instance: it only will extract the...
4
RMWChaos
by: RMWChaos | last post by:
The next episode in the continuing saga of trying to develop a modular, automated DOM create and remove script asks the question, "Where should I put this code?" Alright, here's the story: with a...
13
by: kj | last post by:
Is there a special pythonic idiom for iterating over a list (or tuple) two elements at a time? I mean, other than for i in range(0, len(a), 2): frobnicate(a, a) ?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.