Removing empty node created by Value Mapping Functoid
-
Tuesday, April 13, 2010 12:05 PM
If the first input parameter to Value Mapping functoid is not true, it creates an empty element in the destination which I don't want, how can I get rid of this empty element, if it's empty I do not want it to created in the destination document.
Do let me know how can I achive this within a Map.
All Replies
-
Tuesday, April 13, 2010 12:18 PM
Hi,
Please check your destination schema and see if the element is optional or mandatory and any default value set for it as Value Mapping does not create empty element. Please also see the xsl generated from map that may give you idea what is going on. You can do this by right clicking the map and select Validate. In the output window select xsl file to view xslt.
Regards,
Tariq Majeed
Please mark it as answer if it helps -
Tuesday, April 13, 2010 12:18 PM
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
Remove empty nodes in BizTalk by using XSLT
<?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>
Abdul Rafay - MVP & MCTS BizTalk Server
blog: http://abdulrafaysbiztalk.wordpress.com/
Please mark this as answer if it helps.- Marked As Answer by Umesh G. _ Tuesday, April 13, 2010 1:34 PM
-
Tuesday, April 13, 2010 12:37 PM
To suppress empty tags, use the Value Mapping functoid to control if a tag gets created or not. If the value is evaluated to true, the destination field will be created; otherwise the destination field will not be created. In a looping scenario, use a logical functoid and connect it to the destination record or field. If the condition is evaluated to false, the tag will not be created.
http://msdn.microsoft.com/en-us/library/aa559723(BTS.20).aspx
Thanks, Raja -
Wednesday, April 21, 2010 7:18 AM
Hi Abdul,
The xsl file for removing the empty nodes gives an error if an empty message is passed to it, any idea what changes we need to make in the xsl file so that it does not throw error even if the input message is empty.
Error I get is:
Error 7 Output validation error: Root element is missing.
Do let me know. Thanks.
Sugath
-
Wednesday, April 21, 2010 7:21 AM
For e.g. if the below empty message is passed it will throw an error:
<
ns0:EmployeeInfo xmlns:ns0="http://tempuri.org/">
</
ns0:EmployeeInfo>

