Pages

Remove empty nodes in BizTalk by using XSLT

Tuesday, June 28, 2011

You can get rid of the empty nodes in your map by using a custom functoid and use XSLT script (also given below) and mentioned in this article

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="@@ YOUR NAMESPACE @@" version="1.0" xmlns:ns0="http://Stater.Isvcs.Iface.BO.GetLoanData.ElfV2">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="node()">
        <xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0]|@*)">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()" />
            </xsl:copy>
        </xsl:if>
    </xsl:template>
    <xsl:template match="@*">
        <xsl:copy />
    </xsl:template>
    <xsl:template match="text()">
        <xsl:value-of select="normalize-space(.)" />
    </xsl:template>
</xsl:stylesheet>

2 comments:

  1. Removes all empty nodes
    use xsl:copy (copies the node along with name space)
    use xsl:copy-of (copies the node along with child records, attributes and namespace)

    Ex:

    ReplyDelete

Post Your Comment...