Create Conditional Mappings

The if and choose statements are two ways to create conditions. If statements allow you to specify a single condition. Choose/when/otherwise statements allow you to specify multiple conditions, similar to if/then/else.

To create conditional mapping:
  1. Drag a source to a target to create a mapping.
  2. Click View View options icon, then select Advanced.
  3. In the upper right corner, click Toggle functions Mapper functions icon to launch the Components panel.
  4. Expand XSLT, and drag appropriate XSLT statements onto the target element.
    You can either search or browse for the function.
  5. Drag the if or choose function onto the target element. (for this example, an if statement is dragged to an ID element).

    An if statement is dragged from the Flow Control category of the XSL Constructors section onto the ID target element. The Flow Control category shows options for choose, for-each, and if.

    The if statement is displayed.


    An if statement is highlighted in green in the Target data structure. To the right, the Functions, Operators, and XSL Constructors sections are shown. XSL Constructors is expanded to show the Flow Control category, which includes options for choose and for-each.

  6. If you add a choose statement, you may specify additional when and otherwise conditions.

    A choose statement is selected (indicated by green) in the Target data structure. The XSL Constructors section shows the Flow Control category, with options for choose and for-each.

    1. Highlight the choose action, then drag and drop a when or otherwise statement.

      A when statement is highlighted in green in the Target data structure. The Functions, Operators, and XSL Constructors sections are shown. XSL Constructors is expanded to show the Flow Control category, with options for choose, for-each, if, otherwise, and when.

  7. Click <, then apply your changes when prompted.

Set Default Values in the Mapper

You may have scenarios in which you need to set some fields to default values. The mapper contains a set of functions that you can use to set default values (for example, the when function that you can use to set default values).

For example, the following conditional mapping is performed.


Description of oic_cond_mapping.png follows
Description of the illustration oic_cond_mapping.png

In the payload, you can set the default value in the mapper.


The payload impacted by the statement

This syntax checks if the iD node is present in the payload. If so, it assigns that value. Otherwise, it adds the default value, which in this case is 1000.