MashZone NextGen 10.2 | Appendix | Legacy Presto components | Mashables and Mashups | Mashups in EMML | Writing Mashups in EMML | Controlling Mashup Processing Flow | <if> | <if> Examples
 
<if> Examples
<if> Basics
At a minimum, you define <if> with a condition and add statements inside <if>, such as the following example:
<variables>
<variable name="destination" type="document"/>
<variable name="importRules" type="document"/>
<variable name="currentCountry" type="string"/>
<variable name="local" type="string" default="US"/>
</variables>
...
<if condition="$destination//country != $local">
<invoke service="ImportRules" operation="getRules"
inputvariables="currentCountry" outputvariable="$importRules"/>
</if>
Adding <elseif> or <else>
To include additional conditions, add <elseif> or <else> elements as children of <if>. You can have any number of <elseif> statements. For example:
<if condition="$sortingType/sortBy = 'date'">
<sort intputvariable="$tasks" sortexpr="/task" sortkeys="dueDate"
outputvariable="$tasks"/>
<elseif condition="$sortingType/sortBy = ’name’">
<sort intputvariable="$tasks" sortexpr="/task" sortkeys="description"
outputvariable="$tasks"/>
</elseif>
<else>
<sort intputvariable="$tasks" sortexpr="/task" sortkeys="priority"
outputvariable="$tasks"/>
</else>
</if>
Breaking
When <if> is inside a looping statement (<for>, <foreach> or <while>), you can also use <break/> inside <if> or <elseif> to stop all subsequent processing for this loop and any further looping.
For examples using <break/>, see the <break> statement.
Working Samples
The following sample mashups use the <if> statement:
*FaultHandlingSample (faulthandling.emml)
*MyGooglePage (igoogle.emml)
*LevenshteinDistanceJoine (levend.emml)
*ErrorHandlingSample (onerror.emml)
*WhileSample (while.emml)
See Mashup Samples for a list of MashZone NextGen mashup samples and where to find them.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Innovation Release