試す:
<xsl:template match="comment()[.='']"/>
サンプル XML:
<?xml version="1.0" encoding="utf-8"?>
<root>
<!---->
<!--above comment line should be deleted-->
<foo>
<!--fooo data-->
<foobar/>
</foo>
</root>
入力 XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="comment()[.='']"/>
</xsl:stylesheet>
出力:
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--above comment line should be deleted-->
<foo>
<!--fooo data-->
<foobar />
</foo>
</root>