[rules-dev] Knowledge Compositions

Mark Proctor mproctor at codehaus.org
Fri Nov 28 02:10:12 EST 2008


Compioitions now work and the new Resource framework is committed. You 
can see the api in action here:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-decisiontables/src/test/java/org/drools/decisiontable/CompositionTest.java
Along with the xml knowledge composition file it is loading:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-decisiontables/src/test/resources/org/drools/decisiontable/composition1Test.xml

The summarised version is:

<composition xmlns='http://drools.org/drools-4.0/composition'
             xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
             xs:schemaLocation='http://drools.org/drools-4.0/composition drools-composition-4.0.xsd' >
    <resource source='classpath:org/drools/decisiontable/composition1Test.drl' type='DRL' />
    <resource source='classpath:data/IntegrationExampleTest.xls' type="DTABLE">
        <decisiontable-conf input-type="XLS" worksheet-name="Tables_2" />
    </resource>
    <resource source='classpath:org/drools/decisiontable/composition2Test.drl' type='DRL' />
</composition>

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "composition1Test.xml", getClass()), KnowledgeType.COMPOSITION );
assertFalse( kbuilder.hasErrors() );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

XML Compisition files support all knowledge types, including other xml knowledge compositions. So one composition can reference and load
other compositions.

I'm not just updating the agent to take advantage of this.

Mark








More information about the rules-dev mailing list