dirname

dirname — Return directory part of a path

Description

This function returns the directory part of a path.


<xsl:template name="dirname">
  <xsl:param name="filename" select="''"></xsl:param>
  <xsl:if test="contains($filename, '/')">
    <xsl:value-of select="substring-before($filename, '/')"></xsl:value-of>
    <xsl:text>/</xsl:text>
    <xsl:call-template name="dirname">
      <xsl:with-param name="filename" select="substring-after($filename, '/')"></xsl:with-param>
    </xsl:call-template>
  </xsl:if>
</xsl:template>