Remove all empty nodes from xml using xslt

Empty nodes in xml payload increase the size of the xml and may cause in parser errros.

For big XML payloads you can use a separate XSLT transformation to handle all the empty nodes.

XSLT transformation –>

<xsl:template match=”node()”>
<xsl:if test=”count(descendant::text()[string-length(normalize-space(.))>0]|@*)”>
<xsl:apply-templates select=”@*|node()”/>

<xsl:template match=”@*”>

<xsl:template match=”text()”>
<xsl:value-of select=”normalize-space(.)”/>

  • Drag and drop a Transform activity and select the XML payload, from which you want to remove empty nodes. Select same XML document for source and target.
  • Create an empty transformation and replace the XSLT fragment given below with the above.

<xsl:template match=”/”>



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s