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
More support for:
IBM Cast Iron Cloud Integration
Software version:
6.4.0.1, 6.4.0.0, 6.3.0.1, 6.3, 6.1.0.15, 6.1.0.12, 6.0.0.6, 5.0.1.8
Operating system(s):
Linux, Windows, Firmware
Document number:
410697
Modified date:
15 June 2018
UID
swg21453180