The
xa:loop and
xa:if are new features for 5.4. The features were implemented over several internal iterations, so you may have a slightly different version depending on which build you tried. These should be fully implemented in the most recent builds; I am testing with the 5.4
Beta release (build 300) and they will be available in our
GA release due out next week. The Designer
Help documentation has also been updated for these two features (although there may be a couple portions that will be updated before GA).
Build 300 does include a snippet for
xa:loop, which looks like the following:
<xa:loop xa:initialize="$xaware:setSessionVariable(i,0)$" xa:condition="$xavar:i$ < 10" xa:adjustment="$xaware:addToSessionVariable(i,1)$">
<iteration number="$xavar:i$" />
</xa:loop>
I believe only
xa:condition is required, which will execute the loop as long as the condition remains true. The example above illustrates how you can use
xa:initialize and
xa:adjustment with an XAware SessionVariable (see functoids) to modify the value used in the condition, so that you execute this loop 10 times (i.e., for 0..9).
For both the
xa:loop and
xa:if constructs, the
xa:condition is evaluated and if the value is "true", the child elements of the condition (loop, if, else, etc.) are executed. You can use a
Functoid or an XAware/XPath expression (allowing XAware substitutions for parameters and element references, and XPath functions) for the condition. One thing to realize is that you must use the correct XPath sytnax. The case above compares an XAware variable to a numeric value so it looks like: "$xavar:i$ < 10". When you compare strings in XPath expressions, single-quotes are required, so a condition to compare an XAware parameter to a value might look something like: " '%state%' = 'CO' ".
Beta (build 300) and later builds, include snippets for Loop, If, and If-elseif-else examples, and all execute correctly as is. You need to create an input parameter named "value" to test various values for the if-elseif-else snippet which is:
<xa:if xa:condition="%value% > 10">
<doSomething />
</xa:if>
<xa:elseif xa:condition="%value% > 5">
<doSomethingElse />
</xa:elseif>
<xa:else>
<otherwiseDoThis />
</xa:else>
For all of the snippets, you can add your own elements (or replace the <iteration/> or <dosomething/> under each condition, including using
BizDoc/BizComp references to execute other components.
In order to pass different values to a SQL BizComp that you are calling N times, you will need to reference some other value (such as the index in the example above, or the Nth elemnt in a hierarchy) to pass dynamic values to the SQL BizComp. If you have a particular example that you can post, or an example that is not working correctly, we can review it and make some further suggestions.
Finally, I wanted to note that you can continue to use iteration techniques that we have used before
xa:loop was introduced. A BizDoc or BizComp is executed once for each matching element specified by
xa:input. So if you have a repeating
XML structure containing 10 elements, and pass that reference as
xa:input, the BizDoc/BizComp will execute 10 times; there is no need for an explicit loop. This is also very useful when you don't know how many input structures you are receiving in each execution - if you have 11 it will execute 11 times, if you have none, it will execute 0 times. In many cases, the dynamic values you want to pass to your SQL BizComp are often contained in an XML structure, so the BizComp is executed the correct number of times, with different values for each execution (such as inserting order items into a database, as shown in some of the tutorials). Again, if you have a specific example you are trying to get working, please attach it to the post, and we'd be happy to review it.