Is the data originally in XML or a structure comparable to a DOM tree?

If the answer is yes, there is a (admittedly not quite simple) approach wherewith
you can solve such problems easily. However, it's probably not worth applying
if there's only one such issue in your app. Just to give you an idea: You use additional facts describing the structure of your data.

I'll furnish details but not unless it's necessary.

-W

On 18 November 2011 20:18, LCode <j_whittlesea@hotmail.com> wrote:
I am trying to write a rule via the guided rule editor and (again!!) I am
really struggling.

The following is a simplified explanation of my scenario:

I have a model where there is one 'Supermarket' object which has a list of
integers 'locationID'. Elsewhere I have another list of 'Place' objects,
each of which has an integer locationReference.

Something like this....

               <Supermarket name = 'asda'>
                       <LocationID>21</LocationID>
                       <LocationID>18</LocationID>
                       <LocationID>19</LocationID>
               </Supermarket>

               <Places>
                       <Place>
                               <LocationReference>21</LocationReference>
                       </Place>
                       <Place>
                               <LocationReference>18</LocationReference>
                       </Place>
                       <Place>
                               <LocationReference>19</LocationReference>
                       </Place>
               </Places>


I need to write a rule that fires when the *order* of locationIDs does not
match the order of the locationReferences. So the above example would be
fine but the model below would not...

               <Supermarket name = 'asda'>
                       <LocationID>18</LocationID>
                       <LocationID>21</LocationID>
                       <LocationID>19</LocationID>
               </Supermarket>

               <Places>
                       <Place>
                               <LocationReference>21</LocationReference>
                       </Place>
                       <Place>
                               <LocationReference>18</LocationReference>
                       </Place>
                       <Place>
                               <LocationReference>19</LocationReference>
                       </Place>
               </Places>

I know that drools does not consider the order of facts in the model,
however since both facts are java.util.Lists I wonder if it possible to
compare the elements at position 0, 1, 2 etc. I am afraid my drl skills are
really not up to scratch.

Any thoughts?

--
View this message in context: http://drools.46999.n3.nabble.com/Ordered-lists-in-drl-tp3519453p3519453.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users