title: XSLT: Output text of current node only and normalize whitespace
body: <p>I have an xml document with the below structure. I'm writing a transformation where I'd like to output the text from node B but ignore the element C and text node "title". Essentially I'd like to extract the text "text goes here" and output it in a new element with all the whitespace normalised. Can anybody help? The below is what I've tried so far.</p>
  
  <pre><code>Input Doc
  &lt;A&gt;
    &lt;B&gt;
      &lt;C&gt;title&lt;/C&gt;
       text goes here
    &lt;/B&gt;
  &lt;/A&gt;
  
  Required output doc
  &lt;d&gt;text goes here&lt;/d&gt;
  
  
  Solution A:
  &lt;xsl:template match="B"&gt;
    &lt;d&gt;       
      &lt;xsl:copy-of select="./text()"/&gt;                
    &lt;/d&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Problem: the whitespace between elements is preserved so I get something like this:</p>
  
  <pre><code>&lt;d&gt;
  
    Text goes here
  
  &lt;/d&gt;
  </code></pre>
  
  <p>I also tried using a value-of statement (<code>&lt;xsl:value-of select="./text()"/&gt;</code>) in the template in solution A but this didn't return any text at all. Is there something wrong with the statement?</p>
  
  <p>I should mention that I have overridden the the default text handling template using the following: <code>&lt;xsl:template match="text()" /&gt;</code></p>
  
  <p>Thanks</p>