If you have ever had a map which begins to look unmanageable with tons of value mappings or extra functoids to simply manage empty nodes you don’t want in your output then you should consider using an XSLT mapping to clean the document up for you.

This involves actually making 2 mappings instead of one, but the upside is faster development with a nominal performance cost. Instead of adding functoids, testing and retesting the output, let the mapper generate the empty nodded and then add an extra mapping step with the following XSLT embedded in it:
<?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>

Save this snippet (or download it here) into your project (open the XSLT and change the namespace!) then create a new map. Make your source and destination schemas the same and in the map properties add your XSLT in the “Custom XSLT path” setting. Place the new map after the “dirty” map; the output should give you an XML document free of extra nodes and a map free of extra functoids.

Of course, if you are doing a strictly messaging based implementation then you are out of luck unless you chain ports together but within an orchestration using XSLT to remove empty nodes might work well for you.

Share This