The initially posted rules "1" and "2" are best practice. You are using a<br>Production Rule Engine, and these rules are what they are made for.<br><br>Doing it in an event handler is not impossible, but it requires you to<br>
implement logic which is (apparently) part of the application domain<br>("There must not be a T without at least one I." and "There must not be an I<br>without its T.") and, moreover, logic which is readily available by the Engine's<br>
workings.<br><br>Don't reinvent the wheel, just start rolling along.<br><br>-W<br><br><br><div class="gmail_quote">On 6 December 2010 13:25, Gabor Szokoli <span dir="ltr"><<a href="mailto:szocske@gmail.com">szocske@gmail.com</a>></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 think I've got your use case: you are making XSLT on steroi^W some<br>
kind of cheese that tastes stimulating and is dense in nutrients but<br>
is in no way controversial.<br>
It would allow user rules for removing stuff, and have built-in rules<br>
for transitively removing unreferenced stuff, right?<br>
<div class="im"><br>
On Mon, Dec 6, 2010 at 12:19 PM, Bruno Freudensprung<br>
<<a href="mailto:bruno.freudensprung@temis.com">bruno.freudensprung@temis.com</a>> wrote:<br>
> I simply plan to read my XML and add the corresponding objects into<br>
> the session, then to fire the rules.<br>
<br>
</div>Ahh, silly me, rule processing is externally initiated in Drools, it's<br>
not some kind of perpetual event engine.<br>
<div class="im"><br>
> Well... I wanted to delegate the whole "logic" to Drools and I imagined<br>
> that I could "listen" to Drools' WorkingMemory's retraction events in<br>
> order to remove the corresponding elements from the input XML.<br>
<br>
</div>Would a query work instead of the event listener then?<br>
I guess it would if the list of remaining stuff is good too...<br>
Or you could mark the unneeded stuff instead of retracting, reason<br>
over the marks, and be able to query the marked stuff directly:<br>
<br>
rule "orphaned Type"<br>
when<br>
t : T(mark != true)<br>
not I(type == t, mark == true)<br>
then<br>
modify (t) {setMark(true)}<br>
end<br>
<br>
rule "orphaned Instance"<br>
when<br>
t : T(mark == true)<br>
I(type == t, mark != true)<br>
<br>
then<br>
modify(i) {setMark(true)}<br>
end<br>
<br>
// transform your rules "1" and "2" as well to sanitize input!<br>
<br>
query "types to delete"<br>
t : T(mark == true)<br>
end<br>
<br>
query "instances to delete"<br>
i : I(mark == true)<br>
end<br>
<div><div></div><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br>