<xsl:template name="fileName">
<xsl:param name="path" />
<xsl:choose>
<xsl:when test="contains($path,'\')">
<xsl:call-template name="fileName">
<xsl:with-param name="path" select="substring-after($path,'\')" />
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($path,'/')">
<xsl:call-template name="fileName">
<xsl:with-param name="path" select="substring-after($path,'/')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$path" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The function recognizes Windows- and Unix-style paths (forward and backward slashes are recognized as path delimiters).
5 comments:
Nice blog. Check out my template to split a string
Thanks this was just what I needed for my transform.
Great code!
I had to convert a input path to a filename to place in the folder tag. I convert all slashes to forward slashes before calling the template.
\
/
www.izuservices.com
Thank you
It is very useful !
Here is how you call this function
xsl:call-template name="fileName"
xsl:with-param name="path" select=""
xsl:call-template
Post a Comment