Created
May 7, 2011 03:34
-
-
Save Svel/960176 to your computer and use it in GitHub Desktop.
XSL template method to convert new lines into <br /> tag
This file contains 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
<?xml version="1.0" encoding="utf-8" ?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output method="html" encoding="windows-1251" indent="yes" /> | |
<xsl:template name="break"> | |
<xsl:param name="text" /> | |
<xsl:choose> | |
<xsl:when test="contains($text,'
')"> | |
<xsl:value-of select="substring-before($text, '
')" disable-output-escaping="yes" /> | |
<br /> | |
<xsl:call-template name="break"> | |
<xsl:with-param name="text" select="substring-after($text,'
')" /> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="$text" disable-output-escaping="yes" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment