Creating a decision table based advanced XML condition
You can create a decision table based advanced XML condition by using the procedure that is described here.
About this task
To create a new decision table based advanced XML condition:
Procedure
- Expand the Java™ project that you created.
- In the Project Explorer hierarchy, select the *.greex file. Right-click Open With > Greex Model Editor.
- Expand the tree structure that appears in the Greex editor
panel. Click on a node from the tree. All the child leaves of the node are listed. The Document Root element contains the root element Greex Rule.
- Select the root element Greex Rule and in the Properties
view, enter the values for various attributes.
The following table describes various attributes of the root element Greex Rule.
In the Properties view, you can view various properties of the selected element. To open the Properties View, from the menu bar, select Window > Show View > Other.... From the list of views under Basic, select Properties.
Attribute
Description
Desc
Enter the description of the Greex rule.
Id
Enter the unique identifier of the Greex rule
Name
Enter the name of the Greex rule.
Return Type
Enter the return type of the Greex rule. For a decision table based Greex rule, the only valid value is "String". The decision table based Greex rule can only return a String.
Type
Enter the Greex rule type. By default, it is a normal Greex rule. To make it a decision table based Greex rule, select "DecisionTable" from the drop-down list.
- Under the root element Greex Rule, create a new IF construct
element as per the requirement. Right-click on the root
element Greex Rule and select New
Child > If from the
pop-up menu. Note: A decision table based Greex rule cannot have an ELSE construct. It can only have a single IF construct.
- Select the If element and in the Properties view, enter the name of the If element in the Name property.
- Under the If element, create a new Condition child element. Right-click on the If element and select New Child > Condition from the pop-up menu.
- Select the Condition element and in the Properties view, enter the name of the Condition element in the Name property.
- As every condition must return a value, under the If element, create a new Return element and specify the appropriate return value for the associated condition in the Value element. Right-click on the If element and select New Child > Return from the pop-up menu.
- Right-click on the Return element and select New Child > Value from the pop-up menu. Enter the value pop-up window displays.
- Enter the value which you want to return if the IF condition gets satisfied.
- Select the Return element. In the
Properties view, in the Default property, specify the default value
which you want to return if none of the IF conditions are satisfied
and in the Output property, specify the value which you want to return
if the IF condition gets satisfied. Note: For a decision table based Greex rule, it is mandatory to give a default return value.
For a decision table based Greex rule, you can define an array of constant values in the Value element. The multiple values are separated using the "|" operator. For example, 5|7|3.
- Under the Condition element, create a new Expression element to specify the expression(s) that you want to evaluate for the condition to be satisfied. Right-click on the Condition element and select New Child > Expression from the pop-up menu. The Edit Expression pop-up window displays.
- In Expression, enter the expression that you want to evaluate.
You can make function calls in the expression by prefixing the function name with "fn:". You can also pass functions to other functions.
Note: You can press Ctrl+Space and select the expression from the drop-down list.For a decision table based Greex rule, you can define an array of constant values for a particular XML attribute in the Expression element. The multiple values are separated using the "|" operator. For example, fn:equals(@orderType, "WEB|STORE|CALLCENTER").
- (Optional) If you want to evaluate a set of expressions
together, you must group the set of expressions. Under the Condition
element, create a new Group element to group a set of expressions
together. Right-click on the Condition element
and select New Child > Group from the pop-up menu.
Now, you can add more than one expression to this group. Right-click on the Group element and select New Child > Expression from the pop-up menu.
You can also add a new Group element to a Group element. Right-click on the Group element and select New Child > Group from the pop-up menu.
Note: Any level of nesting of Group and Expression elements is allowed. - (Optional) Select the Group element
and in the Properties view, specify the operation that you want to
perform on the set of expressions in the "op" property. The valid
values are: "or" and "and".
If you specify the Op property as "or" then a condition gets satisfied if any of the expressions specified in the group evaluates to true.
If you specify the Op property as "and" then a condition gets satisfied only if all of the expressions specified in the group evaluate to true.
- Save your changes by clicking on theSave button.