◷ Reading Time: 2 minutes
An XML document can represent a Glossary definition for different types of rules:
The following table shows the available commands to model a Glossary using XML Language.
Glossary
A glossary is a dictionary that defines all of the business terms and their domains. Or it references a Glossary source within other rule documents.
- name
- Description: Sets the name for a glossary to reference
- Mandatory: Yes (when it is the container for defining Terms)
- Type: String
Term, GlossarySource
<Glossary name="Rating">
<Term name="Price" expression="car.Price" domain="Numeric" />
<Term name="Car is listed in HTPA" expression="probList.Contains(car.Made+'-'+car.Model)" domain="Boolean" />
<Term name="Theft Rating" expression="car.TheftCategory=$value" domain="Options">
<Option value="High" />
<Option value="Low" />
<Option value="Moderate" />
</Term>
<Term name="Car is Convertible" expression="car.Convertible" domain="Boolean" />
</Glossary>
Term
Term defines a business terminology along with its attributes e.g. domain and expression. A term is used to reference expression and domain during modeling and execution of rules.
- name
- Description: Sets the name of terminology
- Mandatory: Yes
- Type: String
- domain
- Description: Sets the domain (type) of the term
- Mandatory: Yes
- Type: Can be any of the following values
- String
- Numeric
- Boolean
- Options
- DateTime
- Range
- expression
- Description: Sets an expression for the domain that is used for the execution
- Mandatory: Yes
- Type: Expression
Option
<Glossary name="Rating">
<Term name="Price" expression="car.Price" domain="Numeric" />
<Term name="Car is listed in HTPA" expression="probList.Contains(car.Made+'-'+car.Model)" domain="Boolean" />
<Term name="Theft Rating" expression="car.TheftCategory=$value" domain="Options">
<Option value="High" />
<Option value="Low" />
<Option value="Moderate" />
</Term>
<Term name="Car is Convertible" expression="car.Convertible" domain="Boolean" />
</Glossary>
Formula
Formula defines an equation that can be evaluated. The formula can be parameterised. For example:
f(x)=x+2
is a formula that accepts a parameter named x and adds 2 to the x and is defined as f.
Formulas can use other formulas as well and they resolve the dependencies on the runtime. For example:
f(x,a, y) = x*2+a+f2(y) f2(y) = 3+y/2m
on the execution, you can use f2 like f2(3,4,5) which:
- calculates f2(5) = 3+ 5/2m = 6.5m
- calculates f2(3,4,5) = 3*2+3+6.5m
When a business glossary document has only Formulas, it is called Boxed Expressions.
- name
- Description: Sets the name of terminology
- Mandatory: Yes
- Type: String
- expression
- Description: Sets an expression for the domain that is used for an execution
- Mandatory: Yes
- Type: Expression
Parameter
A parameter allows defining a local variable for formula and building a statement based on that. The parameter can have only one attributes (parameters) which is name.
<Parameter name="..." />
<Glossary name="Boxed expressions">
<Formula name="f" expression="x+1">
<Parameter name="x" />
</Formula>
</Glossary>
Option
When a Term’s domain is set to Options then the list of the available option can be provided by this command.
- value
- Description: Sets an option’s value of a term
- Mandatory: Yes
- Type: String
<Glossary name="Rating">
<Term name="Price" expression="car.Price" domain="Numeric" />
<Term name="Car is listed in HTPA" expression="probList.Contains(car.Made+'-'+car.Model)" domain="Boolean" />
<Term name="Theft Rating" expression="car.TheftCategory=$value" domain="Options">
<Option value="High" />
<Option value="Low" />
<Option value="Moderate" />
</Term>
<Term name="Car is Convertible" expression="car.Convertible" domain="Boolean" />
</Glossary>
GlossarySource
References a glossary source to be used in a rule or logic definition.
- uri
- Description: Sets address to a glossary, it can be relative file system address or a ruleset address
- Mandatory: Yes (when it is the container for defining Terms)
- Type: String
Note in the Condition section (lone 10 to 15) no expression is used and instead term is used.
<DecisionTable name="Define potential occupant injery rating" processAll="False">
<Declaration>
<Define name="car" direction="In" />
<Using path="FlexRule.Samples.CarInsurance.AirbagType" assembly="Car.Library.dll" />
</Declaration>
<Glossary>
<GlossarySource uri="Glossaries\Rating-BusinessGlossary.xml" />
</Glossary>
<Columns>
<Condition name="Driver's Airbag" term="Has Driver's Airbag" />
<Condition name="Front Passenger's Airbag" term="Has Front Passenger's Airbag" />
<Condition name="Side Panel Airbag" term="Has Side Panel Airbag" />
<Condition name="Roll bar" term="Has Roll bar" />
<Condition name="Convertible" term="Is Convertible" />
<Action name="Occupant Injury Rating" term="Set Occupant Injury Rating" />
<Name name="Rule" />
</Columns>
<Data>
<Row>
<Value>true</Value>
<Value>false</Value>
<Value>false</Value>
<Value></Value>
<Value></Value>
<Value>High</Value>
<Value>R1</Value>
</Row>
</Data>
</DecisionTable>