What is the best way to determine the extension of a file when the
webroot-relative path is stored in a variable, assuming the path may
contain any number of "." characters (so I can't use substring-after)?
For instance if $lcpath contains /images/dir.path/file.png how do I set
$ext to be "png"? Below is the best I have been able to come up with -
suggestions greatly appreciated.
<xsl:variable name="lcpath" select="/images/dir.path/file.png" />
<xsl:variable name="pos">
<xsl:choose>
<xsl:when test="substring( $lcpath, string-length( $lcpath ) - 5, 1
) = '.'">4</xsl:when>
<xsl:when test="substring( $lcpath, string-length( $lcpath ) - 4, 1
) = '.'">3</xsl:when>
<xsl:when test="substring( $lcpath, string-length( $lcpath ) - 3, 1
) = '.'">2</xsl:when>
<xsl:when test="substring( $lcpath, string-length( $lcpath ) - 2, 1
) = '.'">1</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="ext" select="substring( $lcpath, string-length(
$lcpath ) - $pos )" />
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--