Created
July 13, 2012 23:57
-
-
Save jlafitte/3108313 to your computer and use it in GitHub Desktop.
A replace-all XSL template. Very useful if you are stuck in XSLT 1.0 world, but made obsolete in XSLT 2.0+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:template name="string-replace-all"> | |
<xsl:param name="text"/> | |
<xsl:param name="replace"/> | |
<xsl:param name="by"/> | |
<xsl:choose> | |
<xsl:when test="contains($text,$replace)"> | |
<xsl:value-of select="substring-before($text,$replace)"/> | |
<xsl:value-of select="$by"/> | |
<xsl:call-template name="string-replace-all"> | |
<xsl:with-param name="text" select="substring-after($text,$replace)"/> | |
<xsl:with-param name="replace" select="$replace"/> | |
<xsl:with-param name="by" select="$by"/> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$text"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment