[rules-users] Inserting new rule in existing package

Pierre de Leusse pdl at agh.edu.pl
Mon Aug 9 04:21:21 EDT 2010


Hello all,

In my program, I receive series of rules as String in XML along with the
name of package they should be added to.

putRules(String knowledgeSet, List<String> XMLRules)

At the moment, I load from the repository the original state of the
PackageDescr, get all rule names currently in working memory from the
StatefulKnowledgeSession and take out of the PackageDescr what's not in
working memory.

>From there, I try to manually (using DOM4J) insert the new rules in the XML
representation of the PackageDescr and load this one. But...

1) I get the following error when I try to load the latter XML (package node
is in the XML, I've checked):

Code:
	XmlPackageReader xmlReader = new XmlPackageReader(null);
	StringReader sr = new StringReader(documentGlob.asXML());
	PackageDescr packageDescr = xmlReader.read(sr);

Error:
(null: 2, 222): schema_reference.4: Failed to read schema document
'drools.org/drools-5.0.xsd', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the document is not
<xsd:schema>.
(null: 2, 222): cvc-elt.1: Cannot find the declaration of element 'package'.

2) There is a removeRule function on the KnowledgeBase class, why not
addRule, did I miss something?

3) There must be an easier way to do this. Could somebody give me some
pointers?

All the best,
Pierre




More information about the rules-users mailing list