Remove Element Without Child Nodes

Tag(s):

<?xml version="1.0" encoding="UTF-8"?>
<!-- Remove Element Without Child Nodes -->
<!-- Only the 1st level is removed. -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="*">
        <xsl:if test="count(@*) &gt; 0 or count(node()) &gt; 0">
            <xsl:copy>
                <xsl:apply-templates select="@* | node()"/>
            </xsl:copy>
        </xsl:if>
    </xsl:template>
    <xsl:template match="@* | text()">
        <xsl:copy/>
    </xsl:template>
</xsl:stylesheet>