Business Glossary commands

Print Friendly, PDF & Email

◷ 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.

Parameters

  1. name
    1. Description: Sets the name for a glossary to reference
    2. Mandatory: Yes (when it is the container for defining Terms)
    3. Type: String

Internal Commands

Term, GlossarySource

Sample

<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.

Parameters

  1. name
    1. Description: Sets the name of terminology
    2. Mandatory: Yes
    3. Type: String
  2. domain
    1. Description: Sets the domain (type) of the term
    2. Mandatory: Yes
    3. Type: Can be any of the following values
      1. String
      2. Numeric
      3. Boolean
      4. Options
      5. DateTime
      6. Range
  3. expression
    1. Description: Sets an expression for the domain that is used for the execution
    2. Mandatory: Yes
    3. Type: Expression

Internal Commands

Option

Sample

<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:

  1. calculates f2(5) = 3+ 5/2m = 6.5m
  2. calculates f2(3,4,5) = 3*2+3+6.5m

When a business glossary document has only Formulas, it is called Boxed Expressions.

Parameters

  1. name
    1. Description: Sets the name of terminology
    2. Mandatory: Yes
    3. Type: String
  2. expression
    1. Description: Sets an expression for the domain that is used for an execution
    2. Mandatory: Yes
    3. Type: Expression

Internal Commands

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="..." />

Sample

<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.

Parameters

  1. value
    1. Description: Sets an option’s value of a term
    2. Mandatory: Yes
    3. Type: String

Sample

<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.

Parameters

  1. uri
    1. Description: Sets address to a glossary, it can be relative file system address or a ruleset address
    2. Mandatory: Yes (when it is the container for defining Terms)
    3. Type: String

Sample

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>

Updated on July 31, 2019

Was this article helpful?

Related Articles