I am trying to recursively remove 'empty' elements (no children, no attribute or empty attribute) from the xml. This is the XSLT I have
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(*) and
string-length(.)=0 and
(not(@*) or @*[string-length(.)=0])]">
<xsl:apply-templates/>
</xsl:template>
This is the input XML. I expect this XML to be transformed to a empty string
<world>
<country>
<state>
<city>
<suburb1></suburb1>
<suburb2></suburb2>
</city>
</state>
</country>
</world>
But instead I am getting
<world>
<country>
<state/>
</country>
</world>
Can anyone help? I've researched many threads in the forum but still no luck.