Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
minLevel3
outlinetrue
stylenone

 

Description

The if statement selects a statement for execution based on the value of a boolean expression.

...

Syntax Notes

Reserved keywords box

Tag
if
then
else
condition=
  • The boolean expression is evaluated for determining the path to take for execution.
  • If the boolean expression yields true, control is transferred to the first embedded statement. When and if control reaches the end point of that statement, control is transferred to the end point of the if statement.
  • If the boolean expression yields false and if an else part if present, control is transferred to the second embedded statement. When and if control reaches the end point of that statement, control is transferred to the end point of the if statement.
  • If the boolean expression yields false and if an else part if not present, control is transferred to the end point of the if statement.
  • if statements can be nested.

The key part of writing and using the if statement is creating boolean expressions. The boolean expression has to evaluate to true or false. The examples below provide different types 

Examples

Code Block
languagexml
themeEclipse
titleIf then else with constant expression
<if condition="true"> 
<then>
  <Log Message="I am in true block!"/>
</then>
<else>
  <Log Message='I am in false block!"/>
</else>
Code Block
languagexml
themeEclipse
titleIf then else with constant expression
<if condition="true"> 
<then>
  <Log Message="I am in true block!"/>
</then>
<else>
  <Log Message='I am in false block!"/>
</else>
Code Block
languagexml
themeEclipse
titleBoolean value stored in some user defined tags
<if condition="[:RuntimeParams.EnforceKey:]"> 
<then>
  <Log Message="I am in true block!"/>
</then>
<else>
  <Log Message="I am in false block!"/>
</else>
  </if>
</Query>

 

...

Note that XPath expressions can be part expression operands.

Code Block
languagexml
themeEclipse
titleBoolean Expression for string comparison.
<if condition="$ContextData/projectKey eq '[:RuntimeParams.ProjectSettings_ProjectKey:]'">
  <then>
  <Log Message="I am in true block!"/>
</then>
<else>
  <Log Message="I am in false block!"/>
</else>
</if>