Question & Answer
Question
How can I remove an empty attribute from an input XML file?
Answer
Use the XSLT below to remove empty attribute from the XML element:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="node()|SDLT">
<xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0] | @*[string-length(.)>0])">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:template match="@*">
<xsl:if test="string-length(.)>0">
<xsl:copy/>
</xsl:if>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
</xsl:stylesheet>
Historical Number
00000644
Product Synonym
Cast Iron Solution;Cast Iron Operating System;Cast Iron Studio
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21453180