remove %20 AND %3B from filename titles

15 views
Skip to first unread message

Steve

unread,
Dec 31, 2009, 10:46:26 AM12/31/09
to Google Search Appliance/Google Mini - Google Search Appliance/Google Mini
I've used successfully used the following code (thanks Bernardo
Herrera!) to remove spaces from the filenames I display. When I add
another call to replace_string to also remove semicolons from the
title, it repeats fragments of the title 3 times.

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 -->

Reply all
Reply to author
Forward
0 new messages