Get FileName form attachment URL

Jan 10, 2012 at 2:48 PM
Edited Jan 10, 2012 at 2:49 PM

 

When I developed custom upload field there was need 
to get filename from url of attachment in list view. 

For example:
url is
http://horse:7955/Lists/Konkursy/readme.txt

I need filename
readme.txt
_______________________________________________________________________________
Usage:
          <xsl:call-template name="getAttachFileName">
            <xsl:with-param name="string" select="$url" />
          </xsl:call-template>
_______________________________________________________________________________
Template:
  <xsl:template name="getAttachFileName">
    <xsl:param name="string" />
    <xsl:choose>
      <xsl:when test="contains($string, '/')">
        <xsl:call-template name="getAttachFileName">
          <xsl:with-param name="string" select="substring-after($string, '/')" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$string" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>