title: How to convert all "LF" chars to "<br />" tag and show it on the HTML page
body: <p>How to convert all <code>LF</code> chars to <code>&lt;br /&gt;</code> tags and show it on the HTML page?</p>
  
  <p>I have the following example XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="data.xslt"?&gt;
  &lt;data&gt;
  &lt;lines&gt;
  Line 1
  Line 2
  Line 3
  Line 4
  Line 5
  Line 6
  &lt;/lines&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>and I want to show all lines on the HTML page. For this I use the following XSLT transformation:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:output method="html" version="1.0" encoding="utf-8" indent="yes"/&gt;
      &lt;xsl:template match="/"&gt;
          &lt;html&gt;
              &lt;head&gt;
                  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;xsl:variable name="filtered"&gt;
                      &lt;xsl:call-template name="replace"&gt;
                          &lt;xsl:with-param name="string" select="./data/lines"/&gt;
                          &lt;xsl:with-param name="search" select="'&amp;#xA;'"/&gt;
                          &lt;xsl:with-param name="new"&gt;&lt;br /&gt;&lt;/xsl:with-param&gt;
                      &lt;/xsl:call-template&gt;
                  &lt;/xsl:variable&gt;
                  &lt;td align="left"&gt;
                      &lt;xsl:value-of select="$filtered" disable-output-escaping="yes"/&gt;
                  &lt;/td&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template name="replace"&gt;
          &lt;xsl:param name="string"/&gt;
          &lt;xsl:param name="search"/&gt;
          &lt;xsl:param name="new"/&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="contains($string, $search)"&gt;
                  &lt;xsl:value-of select="substring-before($string, $search)"/&gt;
                  &lt;xsl:value-of select="$new"/&gt;
                  &lt;xsl:call-template name="replace"&gt;
                      &lt;xsl:with-param name="string" select="substring-after($string, $search)"/&gt;
                      &lt;xsl:with-param name="search" select="$search"/&gt;
                      &lt;xsl:with-param name="new" select="$new"/&gt;
                  &lt;/xsl:call-template&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="$string"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p><br />
  When I open that XML file in Firefox (I use browser to show XSLT transformation) I will see that result:</p>
  
  <pre><code>Line 1Line 2Line 3Line 4Line 5Line 6 
  </code></pre>
  
  <p>As you see, <code>LF</code> chars were not replaced by <code>&lt;br /&gt;</code> tags.</p>
  
  <p><br />
  But when I use other string, for example <code>EOL</code>:</p>
  
  <pre><code>&lt;xsl:with-param name="new"&gt;EOL&lt;/xsl:with-param&gt;
  </code></pre>
  
  <p>I will see expected result:</p>
  
  <pre><code>EOLLine 1EOLLine 2EOLLine 3EOLLine 4EOLLine 5EOLLine 6EOL 
  </code></pre>
  
  <p><br />
  The problem is with the convert/display <code>&lt;br /&gt;</code> tag.</p>