Altova MobileTogether Designer

Variables and Action Group Results

Home Prev Top Next

You can set up an Action Group to return a value—the Action Group Result. (For example, in the screenshot below, we have declared two parameters, and then multiplied them in a Return action to produce the Action Group Result.) When a Let action is defined, we can assign the Action Group Result to a variable and use the variable in child actions of the Let action.

MTDVarsAGresult01
Note:If a variable contains a nodeset and the nodeset is modified during processing, then the variable is invalidated and cannot be used subsequently. However, this does not apply if only the values of variables in a nodeset have been modified.

 

The steps to carry out for this usage are as follows:

 

1.In the Action Group, declare any parameters that may be needed to generate the required result. Do this by clicking the Add Parameter icon (see screenshot above). After a new parameter has been added, double-click to the right of the parameter's $ symbol, and enter the name of the parameter. In the screenshot above, we have an Action Group named RectangleArea, in which we have declared two parameters named $length and $width. Note that: (i) the parameters have been declared but no values have been defined for them; (ii) the parameters are in scope only within the Action Group, and cannot be used outside it. If a parameter is defined as optional, then it is not an error if it is not used in the definition of the variable (see Step 3 below).

2.Add a Return action. Use an XPath expression to define the result to return. This result will be the Action Group Result that the Let action can use. In the screenshot above, we have defined an expression that multiplies the values of the $length and $width parameters. Note that the Return action is within the Action Group. Consequently, the parameters are in scope.

3.To declare that a variable defined by a Let action will have the value of an Action Group Result, define the Let action as follows (see screenshot below): (i) Double-click to the right of the variable's $ symbol, and enter the name of the variable; (ii) Select the Action Group Result radio button (marked in blue in the screenshot below); (iii) In the combo box at the top (circled in red), select the Action Group that you want to use for the value of the variable; (iv) The parameters of the selected Action Group are listed (in red if mandatory, black if optional); enter the XPath expressions to generate their values. At runtime, these values will be passed to the Action Group's parameters and used to calculate the Action Group Result.

MTDLetActionGroupResult

In the screenshot above, we have given, in the Let action, the variable a name of $area, and selected the RectangleArea Action Group to provide the variable with a value. For the parameter values, we have selected two XML tree nodes to provide the values of the $length and $width parameters (which were declared in the RectangleArea Action Group). When the Let action is executed, the parameter values are passed to the Action Group, where the Return action uses the parameter values in its calculation. The result is returned and becomes the value of the variable defined in the Let action. In our example above, the values of the $length and $width parameters are passed to the RectangleArea Action Group, which multiplies them together and returns the result to the $area variable of the Let action.

4.The variable defined in the Let action can now be used in child actions of the Let action. In the screenshot above, for example, we have used the $area variable to update the Box/Area node.

 

See the description of the Let action for more information.

 

© 2017-2023 Altova GmbH