Created
October 8, 2012 13:40
-
-
Save netsi1964/3852588 to your computer and use it in GitHub Desktop.
XSLT replace
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:variable name="amp"> | |
<xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text> | |
</xsl:variable> | |
<xsl:variable name="crlf" select="' '" /> | |
<xsl:variable name="br"> | |
<xsl:text disable-output-escaping="yes"><![CDATA[<br />]]></xsl:text> | |
</xsl:variable> | |
<xsl:call-template name="string-replace-all"> | |
<xsl:with-param name="text" select="'Your original'" /> | |
<xsl:with-param name="replace" select="$br" /> | |
<xsl:with-param name="by" select="$crlf" /> | |
</xsl:call-template> | |
<xsl:call-template name="string-replace-all_outputEscapingDisabled"> | |
<xsl:with-param name="text" select="'Your original'" /> | |
<xsl:with-param name="replace" select="$br" /> | |
<xsl:with-param name="by" select="$crlf" /> | |
</xsl:call-template> | |
<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> | |
<xsl:template name="string-replace-all_outputEscapingDisabled"> | |
<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)" disable-output-escaping="yes" /> | |
<xsl:value-of select="$by" disable-output-escaping="yes" /> | |
<xsl:call-template name="string-replace-all_outputEscapingDisabled"> | |
<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" disable-output-escaping="yes" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment