469,578 Members | 1,671 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

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 1260


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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Radhika Sambamurti | last post: by
7 posts views Thread by Dave Hansen | last post: by
6 posts views Thread by Gustaf Liljegren | last post: by
11 posts views Thread by dyc | last post: by
13 posts views Thread by kj | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.