<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
You can do this, set it up relationally, this is the "best practice"
way. This is what I told someone else:<br>
<br>
Nested lists and hashmaps aren't good things for rules. Instead what
you should do is break them apart and use a relational object to drive
this. Take at look at the conways game of life example in MR2. There
you'll see I have a grid of Cell objects, in the old version each Cell
had a HashSet of neighbour Cells - this setup doesn't work too well
with Rule Engines. Instead now I have a Neighbour class that acts as a
relation, so I assert all my Cells and then I assert a Neighbour class
for each neighbour pair I create. This creates a cross product, which
you can explioit to drive your application. Basically think
relationally, not nested structures, it's exactly the same problem if
you wanted to represent this information in a database.<br>
<br>
Mark<br>
<br>
Anirvan Majumdar wrote:
<blockquote
 cite="mid:2cb74dd90705151037x30bf0013u8d0e944e41673cd@mail.gmail.com"
 type="cite">Yeah,<br>
  <br>
I'd second that. Mark's approach actually had me all dazed right from
the second line. I need to use Drools to accomplish a rather simple
task, however the suggestions made by Mark had me all lost. <br>
  <br>
My requirement is that I have an <span style="font-style: italic;">input
  </span>XML which my application should parse and output another XML.
The <span style="font-style: italic;">output </span>XML will have
tags and values capturing the required business model. The structure of
the <span style="font-style: italic;">input </span>XML is something
like this:<br>
  <br>
&nbsp;&nbsp;&nbsp; &lt;parent name="aaaaaaa"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;child value="sdfsdfsdf"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;child value="sdfsdfsdf"/&gt;
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;child value="sdfsdfsdf"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;child value="sdfsdfsdf"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;/parent&gt;<br>
  <br>
Now the transformation of this input XML has to be done condition to
certain rules which our client will provide us. I thought Drools would
fit in very well. However after reading and acquiring a basic
understanding I came across this particular limitation.
  <br>
  <br>
My problem arises since, the input bean's <span
 style="font-style: italic;">parent </span>tag can have varying number
of <span style="font-style: italic;">child </span>tags. As a
consequence, I can't define a single Bean class to capture this XML
data. I can capture the data in a HashMap, but then I can't access the <span
 style="font-style: italic;">key-value </span>pairs from the "<span
 style="font-style: italic;">when</span>" block of a rule.<br>
  <br>
  <span style="font-style: italic;">Arjun, </span>as you suggested,<br>
- can you tell me whether I can really utilize <span
 style="font-style: italic;">DynaBeans </span>to meet my ends in this
particular case?<br>
- Can you also let me know a simple approach I can adopt? <br>
- also, if <span style="font-style: italic;">eval </span>can be used
in this case, can you pass across an example to show how to access say,
the <span style="font-style: italic;">key-values</span> from a HashMap
set in the asserted Bean object.<br>
  <br>
Amongst the other Rule Engines, I still think that Drools fits in best.
A little help perhaps?<br>
  <br>
Thanks a lot!
  <br>
Anirvan<br>
  <br>
  <br>
  <br>
  <br>
  <div><span class="gmail_quote">On 5/15/07, <b
 class="gmail_sendername">Arjun Dhar</b> &lt;<a moz-do-not-send="true"
 href="mailto:dhar_ar@yahoo.com">dhar_ar@yahoo.com</a>&gt; wrote:</span>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Mark
Proctor &lt;mproctor &lt;at&gt; <a moz-do-not-send="true"
 href="http://codehaus.org">codehaus.org</a>&gt; writes:<br>
    <br>
&gt;<br>
&gt;<br>
&gt; You need to alter the parser and the Extractor api, you also need
to be<br>
&gt; able to deal with ShadowFacts, where we need to know the previous
and
    <br>
&gt; current value.Further to that nested value should not change
without<br>
&gt; notifying the parent fact in the network - i.e. correct network
state<br>
&gt; must always been maintained. It's a complex area, we are looking
at a
    <br>
&gt; work around that allows this declarative language, but rewrites it
as<br>
&gt; an eval - so you don't get the performance advantages - but it's a<br>
&gt; quick work around for now.<br>
&gt; Mark<br>
    <br>
If what you want is the ability to extend the use of the class beyond
what it
    <br>
was designed for (like a Dyna Bean, I think it is that!), then as a
work around<br>
you could use 'eval' over your object methods also, but this practice is<br>
discouraged for a few reasons.<br>
    <br>
The other more sophisticated approach is already given by Mark!
    <br>
    <br>
regards,<br>
Arjun<br>
    <br>
_______________________________________________<br>
rules-dev mailing list<br>
    <a moz-do-not-send="true" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
    <a moz-do-not-send="true"
 href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
  </blockquote>
  </div>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
  </pre>
</blockquote>
<br>
</body>
</html>