[rules-users] Solution for reasoning over XML?

craigparra craigparra at gmail.com
Thu Jan 10 18:04:35 EST 2013


Hi, 

I was looking around trying to find a solution for reasoning over any XML in
drools, without having to convert the XML into java objects, but couldn't
find any example where this had been done. 

I have opted to DOM parse the XML, then recursively wrap every Element node
in a convenience class (XmlElement) and insert as facts.  That is every
element is inserted individually as a fact. 

My conditionals look like: 

$xml : XmlElement(name == 'someName', value == 'someValue') 
$xml : XmlElement(path== '/some/xpathlike/path', value == 'someValue') 
$xml : XmlElement(attribute['someAttr'] == 'someValue') 

or using a DSL: 

An XML element exists 
- named someName with a value of 
- at path /some/xpathlike/path with a value in "someVal","someOtherVal" 

Is this a pattern that other drools users have encountered? Or tried to
solve.   

It seems to work quite well, at least in my scenario - but clearly it has
limitations based on the DOM parse (ie not great for massive XML files).   

Was wondering if anyone else had tried to solve how to use XML as facts? 



--
View this message in context: http://drools.46999.n3.nabble.com/Solution-for-reasoning-over-XML-tp4021454.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list