A decision table can have one or more inputs, also called input clauses. Aninput clause defines the id, label, expression and type of a decision tableinput.
An input clause is represented by an input
element inside a decisionTable
XML element.
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" id="definitions" name="definitions" namespace="http://camunda.org/schema/1.0/dmn">
<decision id="dish" name="Dish">
<decisionTable id="decisionTable">
<input id="input1" label="Season">
<inputExpression id="inputExpression1" typeRef="string">
<text>season</text>
</inputExpression>
</input>
<!-- ... -->
</decisionTable>
</decision>
</definitions>
Input Id
The input id is a unique identifier of the decision table input. It is used bythe Camunda BPMN platform to reference the input in the history of evaluateddecisions. Therefore, it is required by the Camunda DMN engine. It is set asthe id
attribute of the input
XML element.
<input id="input1" label="Season">
<inputExpression id="inputExpression1" typeRef="string">
<text>season</text>
</inputExpression>
</input>
Input Label
An input label is a short description of the input. It is set on the input
XML element in the label
attribute. Note that the label is not required butrecommended, since it helps to understand the decision.
<input id="input1" label="Season">
<inputExpression id="inputExpression1" typeRef="string">
<text>season</text>
</inputExpression>
</input>
Input Expression
An input expression specifies how the value of the input clause is generated.It is an expression which will be evaluated by the DMN engine. It is usuallysimple and references a variable which is available during the evaluation. Theexpression is set inside a text
element that is a child of theinputExpression
XML element.
<input id="input1" label="Season">
<inputExpression id="inputExpression1" typeRef="string">
<text>season</text>
</inputExpression>
</input>
Input Type Definition
The type of the input clause can be specified by the typeRef
attribute on theinputExpression
XML element. After the input expression is evaluated by theDMN engine, it converts the result to the specified type. The supported typesare listed in the User Guide.
<input id="input1" label="Season">
<inputExpression id="inputExpression1" typeRef="string">
<text>season</text>
</inputExpression>
</input>
Note that the type is not required but recommended, since it helps to understandthe possible input values and provides a type safety to be aware of unexpectedinput values.
Input Expression Language
The expression language of the input expression can be specified by theexpressionLanguage
attribute on the inputExpression
XML element. Thesupported expression languages are listed in the User Guide.
<input id="input1" label="Season">
<inputExpression id="inputExpression1" typeRef="string" expressionLanguage="groovy">
<text>season</text>
</inputExpression>
</input>
If no expression language is set then the global expressionlanguage, which is set on the definitions
XML element, is used.
<definitions id="definitions"
name="definitions"
xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
expressionLanguage="groovy"
namespace="http://camunda.org/schema/1.0/dmn">
<!-- ... -->
</definitions>
In case no global expression language is set, the default expression languageis used instead. The default expression language for input expressions is JUEL.Please refer to the User Guide to read more about expressionlanguages.
Input Variable Name
When the input expression is evaluated then the return value is stored in a variable.The name of the variable can be specified by the camunda:inputVariable
extension attribute on the input
element. By default, thename is cellInput
.
To use the attribute you have to define the Camunda DMN namespacexmlns:camunda="http://camunda.org/schema/1.0/dmn
in the XML.
<definitions id="definitions"
name="definitions"
xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd"
xmlns:camunda="http://camunda.org/schema/1.0/dmn"
namespace="http://camunda.org/schema/1.0/dmn">
<decision id="dish" name="Dish">
<decisionTable id="decisionTable">
<input id="input1"
label="Season"
camunda:inputVariable="currentSeason">
<!-- ... -->
</input>
<!-- ... -->
</decisionTable>
</decision>
</definitions>
The variable can be used in an expression of an input entry. For example, theJUEL expression currentSeason != "Fall"
checks if the season input is not"Fall"
.
原文: https://docs.camunda.org/manual/7.9/reference/dmn11/decision-table/input/