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(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users(a)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