With the use of XML entities it is possible to have a master DRL file that includes the contents of several other DRL files, so if you have a huge ruleset, this will allow you to divide those rules up into several smaller files.
The following example will hopefully clarify things. We have one master and two (can be more, of course) DRL files:
Master is master.groovy.drl.
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE rule-set [ <!ENTITY rules-block1 SYSTEM "block1.groovy.drl" > <!ENTITY rules-block2 SYSTEM "block2.groovy.drl" > ]> <rule-set name="Your ruleset name here" xmlns="http://drools.org/rules" xmlns:groovy="http://drools.org/semantics/groovy"> <!-- Just include your blocks of rules here --> &rules-block1; &rules-block2; </rule-set>
While each of the other files contains several rules (they are grouped arbitrarly and note that there is no <rule-set></rule-set> ... just plain <rule></rule>!):
block1.groovy.drl
!-- 1. Starting point -->
<rule name="initial">
<!-- Rule's body according to Drools syntax -->
</rule>
block2.groovy.drl
<!-- 2. Move left --> <rule name="move-left"> <!-- Rule's body according to Drools syntax --> </rule> <!-- 3. Move right --> <rule name="move-right"> <!-- Rule's body according to Drools syntax --> </rule> <!-- ... you got the idea ... -->
In your Java code, you would then simply do something like this:
// ... URL url = new URL( "file:master.groovy.drl" ); ruleBase = RuleBaseBuilder.buildFromUrl( url ); // ... and proceed as usual :-)
Thanks go to Mario Scalas for this FAQ entry.


