title: Need to remove unwanted space element
body: <p>I want to remove the unwanted space element using XSL.</p>
  
  <p>XML I'm testing:</p>
  
  <pre><code>&lt;Body&gt;
     &lt;h1&gt;abc&lt;/h1&gt;
     &lt;h1&gt;efg&lt;/h1&gt;
     &lt;p&gt;efgh&lt;/p&gt;
     &lt;h1&gt; &lt;/h1&gt;
  &lt;/Body&gt;
  </code></pre>
  
  <p>XSL I used:</p>
  
  <pre><code>&lt;xsl:template match="Body"&gt;
     &lt;xsl:copy&gt;
        &lt;xsl:for-each-group select="*" group-adjacent="boolean(self::h1)"&gt;
           &lt;xsl:choose&gt;
              &lt;xsl:when test="current-grouping-key()"&gt;
                 &lt;h1&gt;
                    &lt;xsl:apply-templates select="current-group()/node()"/&gt;
                 &lt;/h1&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                 &lt;xsl:apply-templates select="current-group()"/&gt;
              &lt;/xsl:otherwise&gt;
           &lt;/xsl:choose&gt;
        &lt;/xsl:for-each-group&gt;
     &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>Output I get:</p>
  
  <pre><code>&lt;Body&gt;
     &lt;h1&gt;abcefg&lt;/h1&gt;
     &lt;p&gt;efgh&lt;/p&gt;
     &lt;h1&gt; &lt;/h1&gt;
  &lt;/Body&gt;
  </code></pre>
  
  <p>Output I would like:</p>
  
  <pre><code>&lt;Body&gt;
     &lt;h1&gt;abcefg&lt;/h1&gt;
     &lt;p&gt;efgh&lt;/p&gt;
  &lt;/Body&gt;
  </code></pre>
  
  <p>I need to remove the element having the space value. Please advise. Thanks in advance</p>