Drools

The SXC Drools integration allows you to trigger rules which are based on XPath expressions. This is useful if you are trying to make decisions based on existing XML documents or routing messages within your organization.

Here is an example of what our rules might look like:

package com.envoisolutions.sxc.drools;

import com.envoisolutions.sxc.xpath.XPathEvent;

rule "AddresTest"
    when
        event : XPathEvent( expression == "/order/address[@country]" );
    then
        System.out.println("Success! - " + drools.getRule().getName());
end

To evaluate these rules, you can use the following code:

final DroolsXPathEvaluatorFactory evaluatorFactory = 
    new DroolsXPathEvaluatorFactory();
evaluatorFactory.setPackageStream(getClass().getResourceAsStream("test.drl"));
evaluatorFactory.addPrefix("c", "urn:customer");

XPathEvaluator evaluator = evaluatorFactory.create();
evaluator.evaluate(getClass().getResourceAsStream("test.xml"));

Labels

 
(None)