XSLT call template in BizTalk Mapping

1.1k views Asked by At

I receive a flat file and a Oracle view binding, I need to map schema from these two in to a send flat file. Employee Id is the common field in both the flat file and the Oracle view. I need to check the employee ID on both the input schema also check if the PREFERREDLASTNAME field in the Oracle is not null then send the PREFERREDLASTNAME from the Oracle view otherwise send the Last_Name from the file schema.

Here I am using the XSLT Call template. But I am not sure how to check if the PREFREEDEDLASTNAME is not NULL then set Last_Name as PREFREEDEDLASTNAME otherwise set the Last_Name from the input flat file.

Below is the Map enter image description here

enter image description here

 <xsl:template name="GetLastNameVW_EMP_JOB_DEPT"> 
 <xsl:param name="ID" /> 
 <xsl:element name="Last_Name">
 <xsl:value-of select="//s0:VW_EMP_JOB_DEPTRECORDSELECT[s0:EMPLOYEE_ID = $ID]/s0:PREFERREDLASTNAME" />
 </xsl:element> 
 </xsl:template>

With the above XSLT it looks only for the Employee_Number = EMPLOYEE_ID in both the schemas and sets the Last_Name as PREFERREDLASTNAME and leaves blank if they are not equal. How can I modify my XSLT to perform the condition

1

There are 1 answers

0
felixmondelo On

This is the solution:

<xsl:template name="GetLastNameVW_EMP_JOB_DEPT"> 
<xsl:param name="ID" /> 
 <xsl:param name="LASTNAME" /> 
 <xsl:element name="Last_Name">
   <xsl:choose>
       <xsl:when test="//s0:VW_JAX_EMP_JOB_DEPTRECORD[s0:EMPLOYEE_ID = $ID]/s0:PREFERREDLASTNAME" >
         <xsl:value-of select="//s0:VW_JAX_EMP_JOB_DEPTRECORD[s0:EMPLOYEE_ID = $ID]/s0:PREFERREDLASTNAME" />
       </xsl:when>
       <xsl:otherwise>
         <xsl:value-of select="$LASTNAME" />
       </xsl:otherwise>
   </xsl:choose>
 </xsl:element> 
 </xsl:template>