« XSLT to escape single quotes and double quotes | Home | XSLT to remove the first word of the string »

XSLT to replace substring

<xsl:template name="replace-substring">
      <xsl:param name="value" />
      <xsl:param name="from" />
      <xsl:param name="to" />
      <xsl:choose>
         <xsl:when test="contains($value,$from)">
            <xsl:value-of select="substring-before($value,$from)" />
            <xsl:value-of select="$to" />
            <xsl:call-template name="replace-substring">
               <xsl:with-param name="value" select="substring-after($value,$from)" />
               <xsl:with-param name="from" select="$from" />
               <xsl:with-param name="to" select="$to" />
            </xsl:call-template>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="$value" />
         </xsl:otherwise>
      </xsl:choose>
</xsl:template>

Topics: XSLT | Submitter: admin

One Response to “XSLT to replace substring”

  1. sql replace substring Says:
    April 20th, 2008 at 11:51 am

    [...] ... Write to the alert log from PL/SQL code &middot Fading alerts in JavaScript ...http://code.techinterviews.com/xslt-to-replace-substring/24MySQL :: MySQL 5.0 Reference Manual :: 11.4 String FunctionsThe forms that use FROM are standard sql [...]

Comments

You must be logged in to post a comment.

Keep on coding