It would be great if Drools would come with its example DRL files written in the new lingo rather than the old....
________________________________ From: Mark Proctor [mailto:[EMAIL PROTECTED] Sent: Thu 4/13/2006 4:28 PM To: [email protected] Subject: Re: [drools-user] The DRL notation vs. jbossrules Rule Language - ? As per my email the other day if you were to write an XSLT here is what it would do <parameter identifer="person"> <class>Person</class> </parameter> <java:condition>person.getName().equals("tom")</java:condition> ---------------- person : Person() eval( person.getName().equals("tom") ) ---------------- However that is no longer optimal in Drools 3.0 and should be Person( name == "tom" ) If you need to bind then its p : Person( name == "tom" ) Mark Ronald van Kuijk wrote: > AINAE, but it could be as simple as 'replacing' condition with when and > consequence with then, but I'll let the experts tell me. > > Ronald > > 2006/4/13, Dmitry Goldenberg <[EMAIL PROTECTED]>: > >> I don't understand the relationship between the XML-based DRL notation and >> this new lingo with "when" / "then". >> >> With the DRL notation, my understanding is that you write an XML structure >> like the one I'm including below. How does this change with the when/then >> notation? Thanks. >> >> >> <?xml version="1.0"?> >> >> <rule-set name="SamplePolicyRuleSet" >> >> xmlns="http://drools.org/rules" >> >> xmlns:java="http://drools.org/semantics/java" >> >> xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" >> >> xs:schemaLocation="http://drools.org/rules rules.xsd >> http://drools.org/semantics/java java.xsd"> >> >> >> >> <!-- Imports --> >> >> <java:import>java.lang.Object</java:import> >> >> <java:import>java.lang.String</java:import> >> >> <!-- Utility functions --> >> >> <java:functions> >> >> public boolean f1(com.weblayers.platform.rule.PolicyExecContextcontext) >> >> { >> >> return ...; >> >> } >> >> public boolean f2(com.weblayers.platform.rule.PolicyExecContextcontext) >> >> { >> >> return ...; >> >> } >> >> </java:functions> >> >> >> >> <!-First Rule: IF (P1 AND P2) THEN RETURN OK --> >> >> <rule name="First Rule"> >> >> <!-- Rule parameters --> >> >> <parameter identifier="context"> >> >> <class>MyContext</class> >> >> </parameter> >> >> >> >> <!-- Rule Conditions --> >> >> <java:condition> >> >> f1() && f2() >> >> </java:condition> >> >> >> >> <!-- Rule Consequences --> >> >> <java:consequence> >> >> context.setReturn(Constants.OK); >> >> </java:consequence> >> >> </rule> >> >> >> >> <!-Second Rule: IF (!(P1 AND P2)) THEN RETURN FAILURE --> >> >> <rule name="Second Rule"> >> >> <!-- Rule parameters --> >> >> <parameter identifier="context"> >> >> <class>MyContext</class> >> >> </parameter> >> >> >> >> <!-- Rule Conditions --> >> >> <java:condition> >> >> !(f1() && f2()) >> >> </java:condition> >> >> >> >> <!-- Rule Consequences --> >> >> <java:consequence> >> >> context.setVerdict(Constants.FAIL); >> >> </java:consequence> >> >> </rule> >> >> >> >> </rule-set> >> >> >> >> >> >> > >
