Adding the root object of an XML document
You can add just the root object of an XML document to the rule engine.
About this task
One of the ways you can load an XML document into the rule engine is to add just the root object of an XML document.
For instructions on how to create an XML object from an XML document, see Reading XML documents for the decision engine.
Procedure
The way to add the root object of an XML document depends on the engine that is used:
For the decision engine, use the following code:
IlrXmlObject obj = ...
RuleflowEngine engine = definition.createEngine();
RuleflowEngineInput input = engine.createRuleflowEngineInput();
List<Object> wm = new ArrayList<Object>();
wm.add(obj);
input.setWorkingMemory(wm);
By default, inserting the root object does not carry out a recursive add. If you
want to process rules on sub-objects of the graph, you must navigate the model by using the
in and from keywords in your rules.
Example
Here is an extract from a rule named MatchSession1:
rule MatchSession1 {
when {
?c: Conference();
?s: Session(?t: title.toLowerCase()) in ?c.sessionList;
?p: Participant() in ?c.participantList;
collect String(?t.indexOf(toLowerCase()) != -1) in ?p.interestList
where (size() >= 2);
}
...