Overview
(input: any) => object DecisionTable $Decisions.Parse(input: ( string | XmlNode Xml ))
Arguments
( string |
XmlNode Xml )
inputXml node instance or decision table xml string
Example
Sample decision table xml
Code Block |
---|
|
<MyDecisionTable HitPolicy="Any" Aggregation="">
<OutputLabel>Discount by Customer Category</OutputLabel>
<Inputs>
<Input>
<Label>Customer Category</Label>
<Expression TypeRef="string">Customer.Category</Expression>
<InputValues TypeRef="" />
</Input>
<Input>
<Label>Order Size</Label>
<Expression TypeRef="number">OrderSize</Expression>
<InputValues TypeRef="" />
</Input>
</Inputs>
<Outputs>
<Output TypeRef="number" Name="Discount">
<Label>Discount</Label>
<OutputValues />
<Default>0</Default>
</Output>
</Outputs>
<Rules>
<Rule>
<Description />
<Inputs>
<Input>"Business"</Input>
<Input><10</Input>
</Inputs>
<Outputs>
<Output>0.10</Output>
</Outputs>
</Rule>
<Rule>
<Description />
<Inputs>
<Input>"Business"</Input>
<Input>>=10</Input>
</Inputs>
<Outputs>
<Output>0.15</Output>
</Outputs>
</Rule>
<Rule>
<Description />
<Inputs>
<Input>"Private"</Input>
<Input />
</Inputs>
<Outputs>
<Output>0.05</Output>
</Outputs>
</Rule>
</Rules>
</MyDecisionTable> |
Example
Parsing decision table xml
Code Block |
---|
|
var decisionTableNode = $Xml.SelectSingle('MyDecisionTable');
var fn = $Decisions.Parse(decisionTableNode); |
Example
Providing JSON to evaluate
Code Block |
---|
|
var result = fn({
CustomerCategory: "Business",
OrderSize: 10
}); |
Example
Providing XML Node object to evaluate
Code Block |
---|
|
var dataNode = $Xml.SelectSingle('MyDataInputs');
var result = fn(dataNode); |