Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Unfortunately, the <a href="http://www.w3.org/TR/xpath#function-normalize-space" rel="noreferrer"><code>normalize-space()</code></a> function (used in the answer of andynormancx) does more than deleting newlines</strong>. </p> <p>It deletes all leading and trailing whitespace and <strong>it replaces any group of inner contigious whitespace with a single space character</strong>.</p> <p>In many cases we want to deleteonly one type of a white-space character (as in the current case -- new lines (CR+LF is automatically normalized on reading by the XML parser to just LF).</p> <p><strong>The correct and safe way to do so is by using the standard XPath <a href="http://www.w3.org/TR/xpath#function-translate" rel="noreferrer"><code>translate()</code></a> function</strong>:</p> <pre><code>translate(., '&amp;#xA;', '') </code></pre> <p>returns a string obtained from the string-value of the current node in which any newline character is deleted. </p> <p><strong>Here is an example</strong>:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" 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()"&gt; &lt;xsl:value-of select="translate(.,'&amp;#xA;','')"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When the above transformation is applied on this source XML document</strong>:</p> <pre><code>&lt;t&gt; $LOG: 08880xbpnd $ "embedded blanks must stay" df sd fsd f sd fsd &lt;/t&gt; </code></pre> <p><strong>The result is on one line only, as required, and all embedded spaces are left intact</strong>:</p> <pre><code>&lt;t&gt;$LOG: 08880xbpnd $"embedded blanks must stay"dfsdfsdfsdfsd&lt;/t&gt; </code></pre>
    singulars
    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