StringReplace Template

Sep 8, 2010 at 9:49 AM

I found a clever template here:

Hope it helps.

Sep 29, 2010 at 8:55 AM

Just to make things a little quicker, here's the template from the referenced page:

<xsl:template name="stringreplace">
            <xsl:param name="stringvalue"/>
            <xsl:param name="from"/>
            <xsl:param name="to"/>
                <xsl:when test="contains($stringvalue, $from)">
                    <xsl:value-of select="substring-before($stringvalue, $from)"/>
                    <xsl:if test="contains(substring($stringvalue, 1, string-length($stringvalue) - 1), $from)">
                        <xsl:value-of select="$to"/>
                        <xsl:call-template name="stringreplace">
                            <xsl:with-param name="stringvalue" select="substring-after($stringvalue, $from)"/>
                            <xsl:with-param name="from" select="$from"/>
                            <xsl:with-param name="to" select="$to"/>
                    <xsl:value-of select="$stringvalue"/>

Note that there are other useful things on the page iOnline247 referenced, so be sure to take a look ...
Oct 1, 2010 at 1:22 AM

Thanks, Alex!

May 13, 2011 at 6:33 PM

I found a slightly different template that performs the same function. Not sure which one is "better" but I thought I'd adapt it using some of the naming conventions you've used already and throw it in here for consideration.

<xsl:template name="StringReplace">
  <xsl:param name="TextData"/>
  <xsl:param name="From"/>
  <xsl:param name="To"/>
    <xsl:when test="contains($TextData,$From)">
      <xsl:call-template name="StringReplace">
        <xsl:with-param name="TextData" select="concat(substring-before($TextData,$From),$To,substring-after($TextData,$From))"/>
        <xsl:with-param name="From" select="$From"/>
        <xsl:with-param name="To" select="$To"/>
      <xsl:value-of select="$TextData"/>

May 26, 2011 at 2:00 PM
Edited May 26, 2011 at 2:08 PM

Moved to new thread:

May 26, 2011 at 2:05 PM


I think yours is a little different. Are you simply removing the separating semicolons? You should be able to do that with MultiSelectDisplay?


May 26, 2011 at 2:07 PM

Put it in a new thread, this is different.  Updating this.