I have done a bit of work with rules engines and XML.

There is a standard called RuleML [1], but as you can see from an example it
really does not lend itself well to the core concepts of why you would
typically use XML for rule containment (simple configuration typically being
a goal).  An XML-based rule dialect lends itself toward simple maintenance
where analysts do not have to learn a new dialect, which RuleML certainly
involves a significant ramp-up.

You might find that what you are modeling is actually a business process and
not a rule.  From that perspective, you might find BPEL4WS [3] to fit what
you need out of the box.

There is another XML dialect for rules evaluation called XRE [4] that might
fit the bill for what you are looking for.

I have been looking at BizTalk 2004's implementation of rules a bit, and I
like the concept of long-term storage of "facts". BizTalk Server 2004
supports imports and exports of BPEL for orchestrations.

You might also determine that you really only need a simple evaluation of
criteria using Boolean operations to determine if a set of conditions is
true or not.  For this, I have used the following type of structure.

<RuleConfig>
        <RuleSet Type="Or">
                <RuleSet Type="And">
                        <Rule Expr="LessThan" Field="Customer.Age"
Value="55"/>
                        <Rule Expr="GreaterThan" Field="Customer.Age"
Value="18"/>
                        <Rule Expr="GreaterThan" Field="Customer.Salary"
Reference="Customer.TotalBonuses"/>
                </RuleSet>
                <Rule Expr="Equals" Field="Customer.Status" Value="Exempt"/>
        </RuleSet>
</RuleConfig>

This correlates to the following evaluation:
if(((Customer.Age < 55) && (Customer.Age > 18) && (Customer.Salary >
Customer.TotalBonuses)) || (Customer.Status == "Exempt"))

The restrictions around it are:
RuleSets can contain other RuleSets or Rules,
RuleSets contain at least 1 rule,
Rules have no children.

We extended this at one client to allow a RuleConfig element to have an
"Action" attribute, containing the full type name of an assembly that would
be used if the evaluation of all the containing rulesets yielded a Boolean
"true" result.  This worked pretty well, the same approach you will see in
the Exception Management Application Block's configuration of configuration
handlers.


[1] http://www.dfki.uni-kl.de/ruleml/
[2] http://www.dfki.uni-kl.de/ruleml/exa/0.8/discount.ruleml.txt
[3] http://www-106.ibm.com/developerworks/webservices/library/ws-bpel/
[4] http://www.codecube.net/products/xrengine/xredemos.asp



-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Ali
Sent: Wednesday, January 14, 2004 12:39 PM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Rules Engine in .Net

Can anyone point me to some good reading or give some ideas about
designing a flexible rules engine in .Net ?

I am thinking on the lines of creating a xml based rules schema which can
allow request routing based on some verb.

Thanks
Ali

===================================
This list is hosted by DevelopMentorR  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to