Thursday, 12 September 2013

XSLT: How to exclude only a few empty tags from the output?

XSLT: How to exclude only a few empty tags from the output?

I need to ensure that the empty tags (except the mandatory fields)be
excluded from the output. The mandatory fields should be in the output
even if they are empty
Using the following xslt, I am able to exclude the empty tags. But even
the mandatory fields, if they are empty are removed from the output.
Please advise.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes" method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match= "*[not(@*|*|comment()|processing-instruction()) and
normalizespace()='']"/>
</xsl:stylesheet>

No comments:

Post a Comment