Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From <a href="http://www.w3.org/TR/2008/REC-xml-20081126/#sec-line-ends" rel="noreferrer">http://www.w3.org/TR/2008/REC-xml-20081126/#sec-line-ends</a></p> <blockquote> <p>XML parsed entities are often stored in computer files which, for editing convenience, are organized into lines. These lines are typically separated by some combination of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).</p> <p>To simplify the tasks of applications, the XML processor MUST behave as if it normalized all line breaks in external parsed entities (including the document entity) on input, before parsing, by translating both the two-character sequence #xD #xA and any <code>#xD</code> that is not followed by #xA to a single #xA character.</p> </blockquote> <p>So, it's ok to look for <code>&amp;#xA;</code> (or <code>&amp;#10;</code>). But do note that white space only text nodes from the input may or may not be preserve depending on XML tree provider (MSXSL XML parser doesn't preserve this text nodes). Not white space only text nodes are preserved, of course.</p> <p>Then, this <code>text</code> named template replace new lines with empty <code>br</code> elements in XSLT 1.0:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="text()" name="text"&gt; &lt;xsl:param name="pString" select="."/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($pString,'&amp;#xA;')"&gt; &lt;xsl:call-template name="text"&gt; &lt;xsl:with-param name="pString" select="substring-before($pString,'&amp;#xA;')"/&gt; &lt;/xsl:call-template&gt; &lt;br/&gt; &lt;xsl:call-template name="text"&gt; &lt;xsl:with-param name="pString" select="substring-after($pString,'&amp;#xA;')"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$pString"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>With this input:</p> <pre><code>&lt;root&gt; &lt;text&gt; whatever &lt;/text&gt; &lt;text&gt;and more&lt;/text&gt; &lt;/root&gt; </code></pre> <p>Output:</p> <pre><code>&lt;root&gt; &lt;text&gt;&lt;br /&gt;whatever&lt;br /&gt;&lt;/text&gt; &lt;text&gt;and more&lt;/text&gt; &lt;/root&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload