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: [email protected]
[mailto:[email protected]] On Behalf Of Gupta, Ankit
(Ankit)
        Sent: 29 January 2009 07:22
        To: [email protected]
        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

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to