[rules-users] Parsing XML using Drools

Anstis, Michael (M.) manstis1 at ford.com
Thu Jan 29 04:17:56 EST 2009


It is not clear how you want to use the XML?
 
If the XML represents Facts then you could use a worker Fact and "FROM"
to deserialise them and make them available to WM. For example:-
 
rule "get some XML facts"
    when
        $w : Worker()
        Cheese( ) from $w.getCheesesFromXML();
    then
        //Do something with cheese
    end
 
Obviously the XML need not be true serialised objects (in a JAXB sense)
but simply the properties that "getCheeseFromXML" rehydrates.
 
Drools is not exposing any of the XML libraries; they are merely used by
your code. The above would be (partially) equivalent to:-
 
Worker w = new Worker();
List<Cheese> cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
    wm.insert(c);
}
 
rule "Cheese pre-loaded"
    when
        Cheese( )
    then
        //Do something with cheese
    end
 
Partially equivalent as you could retract Cheese( ) in the second way
which would affect truth maintenance whereas the first way would (I
believe) not.
 
With kind regards,
 
Mike


________________________________

	From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
	Sent: 29 January 2009 07:22
	To: rules-users at lists.jboss.org
	Subject: [rules-users] Parsing XML using Drools
	
	
	Hi All,
	          How can we read and parse a XML file using drools ?
	 
	Does Drools support the SAX or DOM parsing .
	 
	 
	Regards
	 
	Ankit

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090129/72202993/attachment.html 


More information about the rules-users mailing list