cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter C. Verhage" <pete...@zeelandnet.nl>
Subject <xsl:param name="filename"/>
Date Mon, 26 Mar 2001 19:24:40 GMT
Is there also something like the above to get only the path, and not the
filename? I can extract the path of the above using the following XSLT code:

<xsl:param name="filename"/>

<xsl:template name="get-path">
  <xsl:param name="file"/>
  <xsl:param name="path"/>
  <xsl:choose>
    <xsl:when test="string-length($file) > 0 and contains($file, '/')">
      <xsl:call-template name="get-path">
        <xsl:with-param name="file" select="substring-after($file, '/')"/>
        <xsl:with-param name="path" select="concat($path,
substring-before($file, '/'), '/')"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$path"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:variable name="path">
  <xsl:call-template name="get-path">
    <xsl:with-param name="file" select="$filename"/>
    <xsl:with-param name="path"/>
  </xsl:call-template>
</xsl:variable>

But maybe there is a faster way in doing this (btw, this example only works
within a Unix like environment, because it uses the '/' instead of the '\').

Peter


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message