How do I modify substring-after-last to replace multiple characters?
Thanks!
Benardo's code that removes spaces:
<xsl:template name="substring-after-last">
<xsl:param name="url" />
<xsl:param name="substr" />
<!-- Extract the string which comes after the first occurence -->
<xsl:variable name="temp" select="substring-after($url,$substr)"/>
<xsl:choose>
<!-- If it still contains the search string then recursively
process -->
<xsl:when test="$substr and contains($temp,$substr)">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="url" select="$temp" />
<xsl:with-param name="substr" select="$substr" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- replace the spaces in the filename -->
<xsl:call-template name="replace_string">
<xsl:with-param name="find" select="'%20'"/>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="string" select="$temp"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- *** end of substring-after-last -->
My code that makes a mess:
<xsl:template name="substring-after-last">
<xsl:param name="url" />
<xsl:param name="substr" />
<!-- Extract the string which comes after the first occurence -->
<xsl:variable name="temp" select="substring-after($url,$substr)"/>
<xsl:choose>
<!-- If it still contains the search string then recursively
process -->
<xsl:when test="$substr and contains($temp,$substr)">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="url" select="$temp" />
<xsl:with-param name="substr" select="$substr" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- replace the spaces in the filename -->
<xsl:call-template name="replace_string">
<xsl:with-param name="find" select="'%20'"/>
<xsl:with-param name="replace" select="' '"/>
<xsl:with-param name="string" select="$temp"/>
</xsl:call-template>
<!-- replace the semicolons in the filename -->
<xsl:call-template name="replace_string">
<xsl:with-param name="find" select="'%3B'"/>
<xsl:with-param name="replace" select="';'"/>
<xsl:with-param name="string" select="$temp"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- *** end of substring-after-last -->