<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).