Counting Nodes in BizTalk EDI Map

BizTalk No Comments »

image

While working on an BizTalk EDI project, I needed to count dependents on 834 documents. What made this difficult was that the document would contain users and their dependents intermittently. I could have a user with no dependents followed by one with three. I wanted to be able to count the dependents so that I can make some logical decisions during the orchestration. I ended up using an Inline XSLT Call Template to implement the transformation.

The map called a Scripting functoid as shown below:

Map

The transformation script I used looks as follows:

<xsl:template name="Dependents">
    <xsl:param name="parIsEmp" />
    <xsl:param name="parEmpID" />
    <xsl:element name="Dependents">
    <xsl:if test="$parIsEmp = ‘N’">
        <xsl:text>0</xsl:text>
    </xsl:if>
    <xsl:if test="$parIsEmp = ‘Y’">
        <xsl:call-template name="CountDependents">
        <xsl:with-param name="par_EmpID" select="$parEmpID" />
        </xsl:call-template>
    </xsl:if>
    </xsl:element>
</xsl:template>

<xsl:template name="CountDependents">
    <xsl:param name="par_EmpID" />
    <xsl:value-of select="count(//s0:INSLoop1/s0:INS/INS01[$par_EmpID = ../../s0:REF_3/REF02/text() and 'Y' != ../../s0:INS/INS01/text()])" />
</xsl:template>

, , ,

View blog reactions

Bookmark and Share Bookmark and Share
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in