title: Output XSLT <xsl:message> without trailing line break
body: <p>I am using <code>&lt;xsl:message terminate="yes"&gt;</code> to output an error when processing my XML file. That works fine, but when I try to expect that error in RSpec I run into the fact that it is apparently adding a line break to the end of the xsl:message. I don't want to add a weird line break to my test, I'd prefer to remove the line break from the xsl:message.</p>
  
  <p>XML:</p>
  
  <pre><code>&lt;prog Id="fooid"&gt;&lt;/prog&gt;
  </code></pre>
  
  <p>XSLT:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/&gt;
  
  &lt;xsl:template match="prog"&gt;
    &lt;xsl:apply-templates select="." mode="second-pass"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="prog" mode="second-pass"&gt;
    &lt;xsl:message terminate="yes"&gt;&lt;xsl:value-of select="@Id"/&gt; was dropped&lt;/xsl:message&gt;&lt;/xsl:template&gt;
  </code></pre>
  
  <p>In my test code:</p>
  
  <pre><code>it 'raises an error when an item matches no other templates' do
    expect{item_from_xml('&lt;prog Id="fooid"&gt;')}.to raise_error(RuntimeError.new('fooid was dropped'))
  end
  </code></pre>
  
  <p>but the output is:</p>
  
  <pre><code>Failure/Error: expect{item_from_xml('&lt;prog Id="fooid"&gt;')}.to raise_error(RuntimeError.new('fooid was dropped'))
         expected #&lt;RuntimeError: fooid was dropped&gt;, got #&lt;RuntimeError: fooid was dropped
         &gt; with backtrace:
  </code></pre>
  
  <p>You can see the additional line break at the end.</p>
  
  <p>The code for item_from_xml is below:</p>
  
  <pre><code>  def item_from_xml(xml, params=['country', "'US'"])
      xslt = Nokogiri::XSLT(File.read(XSL FILE HERE))
      xslt.transform(Nokogiri::XML(xml), params)
    end
  </code></pre>
  
  <p>I tried to normalize-space in the <code>&lt;value-of select</code> field but that didn't do much as it only effected the @Id. I tried:</p>
  
  <pre><code>&lt;xsl:template match="prog" mode="second-pass"&gt;
    &lt;xsl:message terminate="yes"&gt;&lt;xsl:value-of select="normalize-space(concat(@Id, ' ', 'was dropped'))"/&gt;&lt;/xsl:message&gt;&lt;/xsl:template&gt;
  </code></pre>
  
  <p>but that led to the exact same output. I tried:</p>
  
  <pre><code>&lt;xsl:template match="prog" mode="second-pass"&gt;
    &lt;xsl:message terminate="yes"&gt;&lt;xsl:value-of select="@Id"/&gt;&lt;xsl:text&gt; was dropped&lt;/xsl:text&gt;&lt;/xsl:message&gt;&lt;/xsl:template&gt;
  </code></pre>
  
  <p>again with no luck. I don't want to remove trailing new lines from the entire file, only in this condition where I am using a terminating message. I feel like there is probably something silly I am missing but I'm fairly new to XSLT and I can't seem to get this one.</p>