If Statements

If statements enable you to specify a condition, and if the condition is met, then the specified mapping is output.

When you chose this option, an If statement appears before the selected element, and you must place an XPath expression in the If statement that evaluates to a boolean. If the expression evaluates to true, the specified mapping is performed. If the expression evaluates to false, the mapping is not performed and no value is set for the item. Do not place an If statement around schema data components that are marked as required.

Example of If statement


Note: The example requires a comparison of the value of a boolean element. To obtain the value of the element, the element is coerced into a string using the string() function and then compared to the value of the string "true". See Testing Boolean Values for more information about comparing the value of boolean data components.

In this example, the returnDate schema element is optional. The returnDate element is surrounded by an If statement that evaluates whether the roundTrip element is true. If roundTrip is true, then the element is output, if roundTirp is false, the returnDate element is not output. The expression in the If statement is:

string($MessageData/ns:searchAirlineRequest/ns:parameters/ns0:searchAirline/roundTrip) = "true"