<p>I'm trying to have an XSLT that copies most of the tags but removes empty "<code>&lt;b/&gt;</code>" tags. That is, it should copy as-is "<code>&lt;b&gt; &lt;/b&gt;</code>" or "<code>&lt;b&gt;toto&lt;/b&gt;</code>" but completely remove "<code>&lt;b/&gt;</code>".</p>

<p>I think the template would look like :</p>

<pre><code>&lt;xsl:template match="b"&gt;
  &lt;xsl:if test=".hasChildren()"&gt;
    &lt;xsl:element name="b"&gt;
      &lt;xsl:apply-templates/&gt;
    &lt;/xsl:element&gt;
  &lt;/xsl:if&gt;
&lt;/xsl:template&gt;
</code></pre>

<p>But of course, the "<code>hasChildren()</code>" part doesn't exist ... Any idea ?</p>

I wonder if this will work?
```
```
<xsl:template match="b">
  <xsl:if test="b/text()">
    ...
```
```