XSL string multi-replace function

alfachiu

New Member
how to make this function do multi-replacing ?
exp: replace \[code\]aaa\[/code\] with \[code\]111\[/code\] and replace \[code\]bbb\[/code\] with \[code\]222\[/code\] ...etc\[code\]<xsl:call-template name="replace-string"> <xsl:with-param name="text" select="sm:changefreq"/> <xsl:with-param name="replace" select="'aaa'" /> <xsl:with-param name="with" select="'111?'"/></xsl:call-template><xsl:template name="replace-string"> <xsl:param name="text"/> <xsl:param name="replace"/> <xsl:param name="with"/> <xsl:choose> <xsl:when test="contains($text,$replace)"> <xsl:value-of select="substring-before($text,$replace)"/> <xsl:value-of select="$with"/> <xsl:call-template name="replace-string"> <xsl:with-param name="text" select="substring-after($text,$replace)"/> <xsl:with-param name="replace" select="$replace"/> <xsl:with-param name="with" select="$with"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose></xsl:template>\[/code\]
 
Back
Top