The initially posted rules &quot;1&quot; and &quot;2&quot; 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>(&quot;There must not be a T without at least one I.&quot; and &quot;There must not be an I<br>without its T.&quot;) and, moreover, logic which is readily available by the Engine&#39;s<br>
workings.<br><br>Don&#39;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">&lt;<a href="mailto:szocske@gmail.com">szocske@gmail.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 think I&#39;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>
&lt;<a href="mailto:bruno.freudensprung@temis.com">bruno.freudensprung@temis.com</a>&gt; wrote:<br>
&gt; I simply plan to read my XML and add the corresponding objects into<br>
&gt; the session, then to fire the rules.<br>
<br>
</div>Ahh, silly me, rule processing is externally initiated in Drools, it&#39;s<br>
not some kind of perpetual event engine.<br>
<div class="im"><br>
&gt; Well... I wanted to delegate the whole &quot;logic&quot; to Drools and I imagined<br>
&gt; that I could &quot;listen&quot; to Drools&#39; WorkingMemory&#39;s retraction events in<br>
&gt; 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 &quot;orphaned Type&quot;<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 &quot;orphaned Instance&quot;<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 &quot;1&quot; and &quot;2&quot; as well to sanitize input!<br>
<br>
query &quot;types to delete&quot;<br>
       t : T(mark == true)<br>
end<br>
<br>
query &quot;instances to delete&quot;<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>