Conditional mapping is a very common question in each tech that we use in our projects. Someone asked me how to use conditional mapping in Oracle ICS which encouraged me to write this blog.

So, let’s catch the below case:

  • Suppose there are two Query parameters, called A and B
  • There is another third output variable called C
  • Value of C should be as per below logic:
    • If A & B both are not null then output should be, C  = concat(A | B)
    • If A not null then output should be C  =  A
    • If B not null then output should be C  =  B
So, let’s look how we can achieve the preceding use case with the power of XSLT.
We’ll build our expression with the help of choose function available in Oracle ICS. Below attached screenshot depicts the logic that has been built based on the above logic
Since ICS mapper is very sophisticated, so such complex mapping is very difficult to build using ICS mapper. So I would suggest, export the integration and open the XSLT file and edit the code directly with the help of JDeveloper.
Below is the part of XSLT that has been built to achieve the use case:

<nsmpr0:C xml:id="id_17">
<xsl:choose xml:id="id_18">
<xsl:when test="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A!='' and /nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B!=''">
<xsl:value-of select="concat(/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A, ' | ', /nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B)" />
<xsl:when test="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A!=''">
<xsl:value-of select="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:A" />
<xsl:when test="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B!=''">
<xsl:value-of select="/nstrgmpr:execute/nstrgmpr:QueryParameters/nsmpr1:B" />