[rules-users] Need help with syntax for arrays in rules

DavidIsaac David1 at BPSconsulting.com
Tue Nov 10 22:48:41 EST 2009


Hello-

We are writing rules against complex objects (derived from XML) that contain
nested arrays, notionally like this:

Record {
  Detail[] recordDetails;
}

Detail {
  Activity[] yearlyActivity;
}

Activity {
  int year;
}

Is it really true that I must use a "from" clause to navigate the hierarchy,
assuming that my main program only inserts Record into working memory? 
Right now, I have:

rule "Long way using From"
when
  $r: Record()
  $d: Detail () from $r.recordDetails
  $a: Activity (year == 1990) from $d.yearlyActivity
then
  ...

because I get errors if I try directly navigating the objects:

rule "Short way using Dots"
when
  Record (recordDetails.yearlyActivity.year = 1990)
then
  ...

Is it really true I can't navigate through arrays using dot notation, and I
must use the from clause?  This bit of awkwardness makes my rules
significantly harder to read.  I was hoping for something like XPath where I
can navigate right through repeating elements.  

Apologies in advance for the naieve comparison, and thank for any hints.  
-- 
View this message in context: http://old.nabble.com/Need-help-with-syntax-for-arrays-in-rules-tp26273846p26273846.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list