Is the data originally in XML or a structure comparable to a DOM tree?<br>
<br>
If the answer is yes, there is a (admittedly not quite simple) approach wherewith<br>
you can solve such problems easily. However, it&#39;s probably not worth applying<br>
if there&#39;s only one such issue in your app. Just to give you an idea: You use additional facts describing the structure of your data.<br>
<br>
I&#39;ll furnish details but not unless it&#39;s necessary.<br><br>-W<br><br><div class="gmail_quote">On 18 November 2011 20:18, LCode <span dir="ltr">&lt;<a href="mailto:j_whittlesea@hotmail.com">j_whittlesea@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I am trying to write a rule via the guided rule editor and (again!!) I am<br>
really struggling.<br>
<br>
The following is a simplified explanation of my scenario:<br>
<br>
I have a model where there is one &#39;Supermarket&#39; object which has a list of<br>
integers &#39;locationID&#39;. Elsewhere I have another list of &#39;Place&#39; objects,<br>
each of which has an integer locationReference.<br>
<br>
Something like this....<br>
<br>
                &lt;Supermarket name = &#39;asda&#39;&gt;<br>
                        &lt;LocationID&gt;21&lt;/LocationID&gt;<br>
                        &lt;LocationID&gt;18&lt;/LocationID&gt;<br>
                        &lt;LocationID&gt;19&lt;/LocationID&gt;<br>
                &lt;/Supermarket&gt;<br>
<br>
                &lt;Places&gt;<br>
                        &lt;Place&gt;<br>
                                &lt;LocationReference&gt;21&lt;/LocationReference&gt;<br>
                        &lt;/Place&gt;<br>
                        &lt;Place&gt;<br>
                                &lt;LocationReference&gt;18&lt;/LocationReference&gt;<br>
                        &lt;/Place&gt;<br>
                        &lt;Place&gt;<br>
                                &lt;LocationReference&gt;19&lt;/LocationReference&gt;<br>
                        &lt;/Place&gt;<br>
                &lt;/Places&gt;<br>
<br>
<br>
I need to write a rule that fires when the *order* of locationIDs does not<br>
match the order of the locationReferences. So the above example would be<br>
fine but the model below would not...<br>
<br>
                &lt;Supermarket name = &#39;asda&#39;&gt;<br>
                        &lt;LocationID&gt;18&lt;/LocationID&gt;<br>
                        &lt;LocationID&gt;21&lt;/LocationID&gt;<br>
                        &lt;LocationID&gt;19&lt;/LocationID&gt;<br>
                &lt;/Supermarket&gt;<br>
<br>
                &lt;Places&gt;<br>
                        &lt;Place&gt;<br>
                                &lt;LocationReference&gt;21&lt;/LocationReference&gt;<br>
                        &lt;/Place&gt;<br>
                        &lt;Place&gt;<br>
                                &lt;LocationReference&gt;18&lt;/LocationReference&gt;<br>
                        &lt;/Place&gt;<br>
                        &lt;Place&gt;<br>
                                &lt;LocationReference&gt;19&lt;/LocationReference&gt;<br>
                        &lt;/Place&gt;<br>
                &lt;/Places&gt;<br>
<br>
I know that drools does not consider the order of facts in the model,<br>
however since both facts are java.util.Lists I wonder if it possible to<br>
compare the elements at position 0, 1, 2 etc. I am afraid my drl skills are<br>
really not up to scratch.<br>
<br>
Any thoughts?<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Ordered-lists-in-drl-tp3519453p3519453.html" target="_blank">http://drools.46999.n3.nabble.com/Ordered-lists-in-drl-tp3519453p3519453.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>