◷ Reading Time: 3 minutes
An Xml document can represent a Decision Table. The following table shows the available commands to model a Decision Table using Xml Language.
DecisionTable
Main Decision Table body that contains its definition
This is the main container to define a Decision Table. This element in general is grouped into three sections:
- Declaration of Input, Output, and Import
- Definition of Columns
- Data for the Decision Table
- name
- Description: The name of a decision
- Mandatory: Yes
- Type: Any value (String)
- type
- Description: Description: Type of engine to be used
- Mandatory: No
- Type: Validation, Decision
- processAll
- Description: If true all the rows in the decision table will be executed
- Mandatory: No
- Type: Boolean (true/false)
- multiHitPolicy
- Description: Manages how multiple results can be ordered
- Mandatory: No
- Values: None, OutputOrder, RuleOrder
- aggregation
- Description: Aggregates multiple results into one using a function
- Mandatory: No
- Values: Collect, Sum, Min, Max, Count, Average
- function
- Description: Defines an expression that will be evaluated after Decision Table execution is finished
- Mandatory: No
- Values: An Expression
Declaration
This is command is used to define decision Parameters.
Columns This command defines Name, Condition and Action of rules template within a decision
Data
This section defines the values of rules based on a template that is defined in Columns.
<DecisionTable name="Define potential occupant injury rating" processAll="False">
</DecisionTable>
Glossary
A glossary is a dictionary that defines all the business terms and their domains.
Use this link to see the full list of glossary commands.
Columns
This command structures the columns of a Decision Table.
- condition
- Description: Name of a Boolean variable that checks the continuation of the iteration condition
- Mandatory: Yes
- Type: String (name of variable
<Columns>
<Condition name="Min" expression="person.Age>=$value" />
</Columns>
Condition
This command defines a column of a Decision Table that holds a template for validating a condition. This is an expression that uses template mechanisms. $value refers to values of the cells of this column, as shown below.
A condition can participate in the discrimination network when the discriminator attribute is set to true.
- name
- Description: The name of a column
- Mandatory: Yes
- Type: String
- expression
- Description: Expression of the condition to be evaluated
- Mandatory: When no ‘term’ is defined
- Type: String (expression and template)
- term
- Description: Refers to a Glossary Term’s name
- Mandatory: When no ‘expression’ is defined
- Type: String (name of a term)
- discriminator
- Description: When a column is defined as a discriminator, true; otherwise false. (default is false)
- Mandatory: no
- Type: boolean (true or false)
<Columns>
<Condition name="Min" expression="person.Age>=$value" />
<Condition name="Max" expression="person.Age<=$value"/>
</Columns>
Action
This command structures the columns of a Decision Table as an action. Action can be in two types:
- Notice: To write a notice in a notification (set type to notice)
- Or using any expressions directly (e.g., call a method, assign a value). See Expression. (leave type empty)
- name
- Description: Represents the name of the column
- Mandatory: Yes
- Type: String
- type
- Description: type of action. If this is not set then expression should use the full evaluation expression. For more information check Expression
- Mandatory: No
- Type: Notice (Obsoleted values: Set, Call)
- expression
- Description: The expression template of an action or notices message
- Mandatory: When no ‘term’ is defined
- Type: String (Expression)
- term
- Description: Refers to a Glossary Term’s name
- Mandatory: When no ‘expression’ is defined
- Type: String (name of a term)
- variable
- Description: name of the variable that the expression targets
- Mandatory: Yes if the type is set
- Type: String (parameter name)
Notice Action
- notice (only valid when type is set to ‘Notice’ )
- Description: specifies the type of notice message
- Mandatory: No
- notification (When notice action)
- Description: Allows grouping notices in different categories
- Mandatory: No
- Type: string (no space is allowed)
- useMessageId (When notice action)
- Description: specifies the values for notice messages will be used as messageId
- Mandatory: No
- Type: bool (true/false)
Array
When Action applies on array, below parameters are required:
- onArray
- Description: reference to the parameter/expression that is the source of array/collection
- Mandatory: Yes
- Type: Parameter name or expression
- elementName
- Description: reference to each individual element on the array/collection
- Mandatory: Yes
- Type: Parameter name
Action with no type specified as an direct expression:
<Columns>
<Condition name="Min" expression="person.Age ge $value" />
<Condition name="Max" expression="person.Age le $value" />
<Action name="Title" expression="title = $value"/>
</Columns>
Action with type specified.
<Columns>
<Condition name="Min" expression="person.Age ge $value" />
<Condition name="Max" expression="person.Age le $value" />
<Action name="Title" expression="title" />
</Columns>
Action with type of ‘Notice’ to write messages using Notification
<Columns>
<Condition name="Product Exists?" expression="product.Found == $value" />
<Condition name="Points > 20" expression="((product.Quantity * product.Point) > 20)" />
<Action name="Error Message" expression="$value" type="Notice" />
<Action name="Success Message" expression="$value" type="Notice" notice="Information" />
</Columns>
Name
This command defines the name of rule/logic in a Decision Table.
<Columns>
<Condition name="Min" expression="person.Age ge $value" />
<Condition name="Max" expression="person.Age le $value"/>
<Name />
</Columns>
Priority
In Decision Table by default, all rules will be executed from top to down. For a complex Decision Table, this priority of execution can be changed by the priority column. The priority value in a row must have a numeric value, otherwise, it is considered as 0.
<Columns>
<Condition name="Min" expression="person.Age ge $value" />
<Condition name="Max" expression="person.Age le $value"/>
<Priority />
</Columns>
GroupName
In a complex Decision Table, rules can be grouped in multiple different sections. This can be used to manage a complex decision behaviour in combination with a Priority column. When the rules require grouping and each group of rules has its own priority, groupNamecan be used.
<Columns>
<Condition name="Min" expression="person.Age ge $value" />
<Condition name="Max" expression="person.Age le $value"/>
<GroupName />
</Columns>
Data
This command structures the data of a Decision Table. The data part of the table must be encapsulated by Row and then by Value element in the xml. Each value in the data section represents a positive condition, if a negative condition is required it should be prefixed by ‘not:’.
Decision Table supports iterating through items of a list and processes them. To do that, the on and childName parameter must be set.
- on
- Description: Defines a list of items to iterate through
- Mandatory: No
- Type: Expression
- childName
- Description: Defines the name of parameter, each item in the list will be referenced
- Mandatory: Yes, when ‘on’ is defined
- Type: String (Parameter name)
<DecisionTable name="person growing state">
<Declaration>
<Define name="person" direction="In"/>
<Define name="title" direction="Out"/>
</Declaration>
<Columns>
<Condition name="Min" expression="person.Age ge $value" />
<Condition name="Max" expression="person.Age le $value"/>
<Action name="Title" type="set" variable="title" expression="$value"/>
<Action name="Title" expression="person.SetTitle($value)"/>
</Columns>
<Data>
<Row>
<Value>0</Value>
<Value>3</Value>
<Value>infant</Value>
</Row>
<Row>
<Value>4</Value>
<Value>6</Value>
<Value>kid</Value>
</Row>
<Row>
<Value>7</Value>
<Value>18</Value>
<Value>teen</Value>
</Row>
<Row>
<Value>19</Value>
<Value>23</Value>
<Value>young</Value>
</Row>
<Row>
<Value>not: 24</Value>
<Value>99999</Value>
<Value>adult</Value>
</Row>
</Data>
</DecisionTable>
CallDecisionTable
This is an integration point between different engines and Decision Table definitions. When other rules require calls to a Decision Table they can use this command.
All output parameters of a decision will automatically be copied on the parent context.
- contextMode
- Description: Set context behaviour to call to other rules and logic. If set to Shared, the current context will be used for the target rule. Otherwise a new one is created.
- Mandatory: Yes
- Type: String (Shared/New)
DecisionTableSource
- uri
- Description: Where is the source of the external DecisionTable to be run?
- Mandatory: Yes
- Type: Physical file or RuleSet address
DecisionTable integrated into a Flow.
<Activity name="ActivityD">
<CallDecisionTable contextMode="New">
<DecisionTableSource uri="AgeTitle.xml" />
<Param name="person" ref="person"/>
</CallDecisionTable>
<Transition name="tr6" to="end"/>
</Activity>
DecisionTable integrated into a Procedure.
<CallDecisionTable contextMode="Shared">
<DecisionTableSource uri="AgeTitle.xml"/>
</CallDecisionTable>