Wednesday, May 25, 2011

Conditional mapping in an XSLT in WID

In this tutorial we want to map a value only if it is not empty. If it is empty, we want to use another value.

The input data of our datamap will have 2 fields: cban and iban.  If the iban field is empty, use cban.

Drag a connection from the iban field to the bankaccount field (our target). Change the "move" to "if"



Click in the little blue box of your transformation and make sure you see the Properties view of your transformation. In the Condition tab of the properties, enter the following expression:

$iban!= ''

This states this transformation will only be executed if the iban field does not equal an empty string. Now to define the actual transformation, we need to click the "If" in the blue box of the transformation. This will open a new transformation editor, where you can specify that the iban field should be copied tot the  bankaccount field.





Now how  do we add the "else" clause? Hover your mouse over the blue box of our conditional transformation again (you can reach it by clicking XSLTransformation1_req_1 as seen in the screenshot above).
The first icon will create a new condition (else if), the second one an else.  Click on the "else" icon.
You will see a new blue box appearing beneath your "if" box. This new "else" box needs to be connected as well. Connect the icban value to the "else" box, and the "else" box to the bank account. Also create an actual mapping by clicking on the "else" word.



No comments:

Post a Comment