Reputation: 221
I have the string for example :
<path> c:/users/xyz/test_files/test.xml </path>
and I would like to get the string before last '/' that is:
c:/users/xyz/test_files
Thanks in Advance.
Upvotes: 2
Views: 2510
Reputation: 167716
<xsl:template match="path">
<xsl:variable name="p" select="string-join(tokenize(., '/')[position() lt last()], '/')"/>
</xsl:template>
should do.
Upvotes: 1
Reputation: 52888
Try something like this:
<xsl:variable name="tokens" select="tokenize(.,'/')"/>
<xsl:value-of select="$tokens[not(.=$tokens[last()])]" separator="/"/>
This assumes the current context is path
.
Upvotes: 3