Hi All,
I am trying been playing around with drools and I wanted to know if any
one can give me an example of a rule written in pure DSL like in conway
which passes a parameter to a function/method which is part of a
condition or an action.
I have pasted conway.xsd and conway.dsl.drl below.
To give an example of what I need, in the rules mentioned below, what do
I need to do to pass one/multiple parameter(s) to the method "killCell"
and how should I define that in the xml and xsd.
TIA
Saurabh
=============== Rules Files ============================
<?xml version="1.0"?>
<rule-set name="conway"
xmlns="http://drools.org/rules"
xmlns:conway="http://drools.org/semantics/conway"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/rules rules.xsd
http://drools.org/semantics/conway conway.xsd">
<rule name="Kill The Overcrowded">
<conway:condition cellName="cell">
<conway:cellIsAlive/>
<conway:cellIsOverCrowded/>
</conway:condition>
<conway:actions cellName="cell">
<conway:killCell/>
</conway:actions>
</rule>
<rule name="Kill The Lonely">
<conway:condition cellName="cell">
<conway:cellIsAlive/>
<conway:cellIsLonely/>
</conway:condition>
<conway:actions cellName="cell">
<conway:killCell/>
</conway:actions>
</rule>
<rule name="Give Birth">
<conway:condition cellName="cell">
<conway:cellIsDead/>
<conway:cellIsRipeForBirth/>
</conway:condition>
<conway:actions cellName="cell">
<conway:giveBirthToCell/>
</conway:actions>
</rule>
</rule-set>
==============Schema definition ===================
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://drools.org/semantics/conway"
elementFormDefault="qualified"
xmlns:conway="http://drools.org/semantics/conway"
xmlns:rules="http://drools.org/rules">
<xs:import namespace="http://drools.org/rules"
schemaLocation="rules.xsd"/>
<xs:element name="condition"
substitutionGroup="rules:abstractCondition">
<xs:complexType>
<xs:all>
<xs:element ref="conway:cellIsAlive" minOccurs="0"
maxOccurs="1"/>
<xs:element ref="conway:cellIsDead" minOccurs="0"
maxOccurs="1"/>
<xs:element ref="conway:cellIsOverCrowded"
minOccurs="0" maxOccurs="1"/>
<xs:element ref="conway:cellIsRipeForBirth"
minOccurs="0" maxOccurs="1"/>
<xs:element ref="conway:cellIsLonely" minOccurs="0"
maxOccurs="1"/>
</xs:all>
<xs:attribute name="cellName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="actions"
substitutionGroup="rules:abstractConsequence">
<xs:complexType>
<xs:sequence>
<xs:choice>
<xs:element ref="conway:killCell"/>
<xs:element ref="conway:giveBirthToCell"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="cellName" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="killCell"/>
<xs:element name="giveBirthToCell"/>
<xs:element name="cellIsAlive"/>
<xs:element name="cellIsDead"/>
<xs:element name="cellIsOverCrowded"/>
<xs:element name="cellIsLonely"/>
<xs:element name="cellIsRipeForBirth"/>
</xs:schema>