Versions Compared

Key

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

...

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

Using XPath Boolean Expressions

There are two ways in which XPath Expressions can be used as part of boolean expression.

a) XPath as part of individual operand of the expression. For example: $ContextData/projectkey below.

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>

b) Whole boolean expression itself can be XPath expression. This is done using by starting the expression with "/"

Code Block
languagexml
themeEclipse
titleEntire Boolean Expression as XPath
<if condition="/'[:$Macro.Argument.StopWid:]' != '' and '[:$Macro.Argument.StopTarget:]' != ''">
  <then>
  <Log Message="I am in true block!"/>
</then>
<else>
  <Log Message="I am in false block!"/>
</else>
</if>

Using Multiple operands

Take a special note in second expression the >= within boolean expression must be escaped. For example: >= is written as &gt;=

Code Block
languagexml
themeEclipse
titleMultiple Operands
<if condition="[:$Macro.Argument.RouteLoc:]/not(boolean(Site)) and '[:$Macro.Argument.SelfWid:]' != '' and '[:$Macro.Argument.StopTarget:]' != ''">
    <then>
  <Log Message="I am in true block!"/>
</then>
<else>
  <Log Message="I am in false block!"/>
</else>
</if>
 
<if condition="/'[:$Macro.Argument.SiteCur:]' = '[:CONFIG.CompanyId:]' or
                       [:$ProcessData.$BTV.Worker.SlackCounter:] &gt;= [:CONFIG.RULES.MaxWorkerSlack:] or
                       [:$LocalData.Rand:] &gt; [:$ProcessData.$BTV.Worker.SlackTendency:]">
 <then>
   <Log Message="I am in true block!"/>
 </then>
 <else>
   <Log Message="I am in false block!"/>
 </else>
</if>

Nested If Statements

Note that if you do not have else, usage of <then> is optional.

Code Block
languagexml
themeEclipse
titleMultiple Operands
<if condition="/'[:$Macro.Argument.StopWid:]' != '' and '[:$Macro.Argument.StopTarget:]' != ''">
        <Log Message="I am in true block!"/>
        <if condition="/'[:$Macro.Argument.SiteCur:]' = '[:CONFIG.CompanyId:]' or
                       [:$ProcessData.$BTV.Worker.SlackCounter:] &gt;= [:CONFIG.RULES.MaxWorkerSlack:] or
                       [:$LocalData.Rand:] &gt; [:$ProcessData.$BTV.Worker.SlackTendency:]">
        <Log Message="I am in true, true block!"/>
        </if>
</if>