<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 11/09/2010 07:17, Greg Barton wrote:
<blockquote cite="mid:951850.81385.qm@web81505.mail.mud.yahoo.com"
type="cite">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font: inherit;" valign="top">As opposed to data
wrapped in a Fact? I suppose you could use java.util.Map
instead of Fact and write rules around that. Or you could
use a strongly typed POJO, which drools is optimized for.
For translating the xml use something like JAXB or
XStream. (I'm preferring XStream these days.)<br>
</td>
</tr>
</tbody>
</table>
</blockquote>
Edson and I have been discussing how to have better "out of the box"
xml support that doesn't need transformation. It's a lot of work,
but an interesting project if anyone is interested.<br>
<br>
The first aspect is to allow the type and the property accessors to
be dynamically defined<br>
declare Element<br>
@type( nodeName )<br>
@property( get( $1 ) )<br>
end<br>
<br>
Where $1 is the interpolation point for the passed property name.
That would then allow access to Dom Elements as though they were
natural facts. Same can be done for Maps, or similar constructs<br>
declare Map<br>
@type( get( "type" ) //the type is a key in the Map<br>
@propert( get( $1 ) )<br>
end<br>
<br>
declare MyFact<br>
@type( type ) //The type is field<br>
@property( getProperty( $1 ) ) // all properties are via this
getter<br>
end<br>
<br>
If you look at the expiremental FactTemplates you can see the guts
of how fields are accessed and figure out how to plumb this all up.
Then there is the RHS, which is a big more difficult, if you want
the properties supported as named fields, and not emulated getters.<br>
<br>
The other aspect to this would be support for a STAX parser. Here as
it does a single parse of the XML it'll emit events which represent
the DOM element, as long as each event is emitted references the
Parent and Rete only keeps hold events which are likely to match let
the rest be GC'd. Then we have a powerful STAX single pass based
parser with advanced reasoning, ideal for countent routers.<br>
<br>
Any takers? :)<br>
<br>
Mark<br>
<blockquote cite="mid:951850.81385.qm@web81505.mail.mud.yahoo.com"
type="cite">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="font: inherit;" valign="top"><br>
--- On <b>Fri, 9/10/10, Donald Winston <i><a class="moz-txt-link-rfc2396E" href="mailto:satchwinston@yahoo.com"><satchwinston@yahoo.com></a></i></b>
wrote:<br>
<blockquote style="border-left: 2px solid rgb(16, 16,
255); margin-left: 5px; padding-left: 5px;"><br>
From: Donald Winston <a class="moz-txt-link-rfc2396E" href="mailto:satchwinston@yahoo.com"><satchwinston@yahoo.com></a><br>
Subject: Re: [rules-users] Hold the Beans!<br>
To: "Rules Users List"
<a class="moz-txt-link-rfc2396E" href="mailto:rules-users@lists.jboss.org"><rules-users@lists.jboss.org></a><br>
Date: Friday, September 10, 2010, 9:06 PM<br>
<br>
<div id="yiv18163002">
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);">So unlike Jess, Drools can or
cannot use asserted facts from a data structure and
can only use data wrapped in a bean?</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><br>
</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);">/* Assert ordered or unordered
facts from the session's document. A deftemplate
with matching </div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span> * id and slots
for each "fact" element should already exist for
unordered facts.</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span> */</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">public</span> <span
style="color: rgb(147, 26, 104);">void</span>
assertDocument(Document document, Rete engine) <span
style="color: rgb(147, 26, 104);">throws</span>
JessException {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Iterator facts
= (document.getRootElement().getChildren(<span
style="color: rgb(56, 52, 255);">"fact"</span>)).iterator();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">while</span>
(facts.hasNext() == <span style="color: rgb(147,
26, 104);">true</span>) {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Element
factElement = (Element)facts.next();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>String id =
factElement.getAttributeValue(<span style="color:
rgb(56, 52, 255);">"id"</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Fact fact = <span
style="color: rgb(147, 26, 104);">new</span>
Fact(id, engine);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Iterator slots
= (factElement.getChildren(<span style="color:
rgb(56, 52, 255);">"slot"</span>)).iterator();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">while</span>
(slots.hasNext() == <span style="color: rgb(147,
26, 104);">true</span>) {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Element
slotElement = (Element)slots.next();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>String name =
slotElement.getAttributeValue(<span style="color:
rgb(56, 52, 255);">"name"</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>String type =
slotElement.getAttributeValue(<span style="color:
rgb(56, 52, 255);">"type"</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">if</span>
(slotElement.getChildren(<span style="color: rgb(56,
52, 255);">"value"</span>).size() == 1) {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>String value =
slotElement.getChild(<span style="color: rgb(56, 52,
255);">"value"</span>).getText();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>fact.setSlotValue(name,
getValue(type, value));</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">else</span> {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>ValueVector
valueVector = <span style="color: rgb(147, 26,
104);">new</span> ValueVector();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Iterator values
= (slotElement.getChildren(<span style="color:
rgb(56, 52, 255);">"value"</span>)).iterator();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">while</span>
(values.hasNext() == <span style="color: rgb(147,
26, 104);">true</span>) {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>String value =
((Element)values.next()).getText(); </div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>valueVector.add(getValue(type,
value));</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>fact.setSlotValue(name,
<span style="color: rgb(147, 26, 104);">new</span>
Value(valueVector, RU.<span style="color: rgb(0, 39,
204);">LIST</span>));</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}<span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span></div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>} </span>//while
slots</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>engine.assertFact(fact);</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>} </span>//while
facts</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}</div>
<p style="margin: 0px; font: 11px Monaco; min-height:
15px;"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><br
class="yiv18163002webkit-block-placeholder">
</p>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span></span>/*</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span> * Output the
fact base to the response output stream.</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span> * Intended for
debugging. Override to do your own processing.</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(78, 144, 114);"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span> */</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">public</span>
String processResults(HttpServletRequest request,
HttpServletResponse response, </div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Rete engine) <span
style="color: rgb(147, 26, 104);">throws</span>
IOException {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>PrintWriter
writer = response.getWriter();</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(56, 52, 255);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>writer.println(</span>"<html><head><title>Jess
Results</title></head>"<span
style="color: rgb(0, 0, 0);">);</span></div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(56, 52, 255);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>writer.println(</span>"<body><h1>PrettyPrint
listFacts()</h1>"<span style="color: rgb(0, 0,
0);">);</span></div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>writer.println(<span
style="color: rgb(56, 52, 255);">"<pre>"</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Iterator facts
= engine.listFacts();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">while</span>
(facts.hasNext() == <span style="color: rgb(147,
26, 104);">true</span>) {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>Fact fact =
(Fact)facts.next();</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>writer.println(<span
style="color: rgb(147, 26, 104);">new</span>
PrettyPrinter(fact));</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>writer.println(<span
style="color: rgb(56, 52, 255);">"</pre>"</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>writer.println(<span
style="color: rgb(56, 52, 255);">"</body></html>"</span>);</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(147, 26, 104);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span></span>return<span
style="color: rgb(0, 0, 0);"> </span>null<span
style="color: rgb(0, 0, 0);">;</span></div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font: 11px Monaco;
min-height: 15px;"><br>
</div>
<p style="margin: 0px; font: 11px Monaco; min-height:
15px;"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><br
class="yiv18163002webkit-block-placeholder">
</p>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">private</span>
Value getValue(String type, String value) <span
style="color: rgb(147, 26, 104);">throws</span>
JessException {</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">if</span> (<span
style="color: rgb(56, 52, 255);">"STRING"</span>.equals(type)
== <span style="color: rgb(147, 26, 104);">true</span>)</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">return</span> <span
style="color: rgb(147, 26, 104);">new</span>
Value(value, RU.<span style="color: rgb(0, 39,
204);">STRING</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">else</span> <span
style="color: rgb(147, 26, 104);">if</span> (<span
style="color: rgb(56, 52, 255);">"INTEGER"</span>.equals(type)
== <span style="color: rgb(147, 26, 104);">true</span>)</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">return</span> <span
style="color: rgb(147, 26, 104);">new</span>
Value(Integer.parseInt(value), RU.<span
style="color: rgb(0, 39, 204);">INTEGER</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">else</span> <span
style="color: rgb(147, 26, 104);">if</span> (<span
style="color: rgb(56, 52, 255);">"FLOAT"</span>.equals(type)
== <span style="color: rgb(147, 26, 104);">true</span>)</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">return</span> <span
style="color: rgb(147, 26, 104);">new</span>
Value(Float.parseFloat(value), RU.<span
style="color: rgb(0, 39, 204);">FLOAT</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">else</span> <span
style="color: rgb(147, 26, 104);">if</span> (<span
style="color: rgb(56, 52, 255);">"SYMBOL"</span>.equals(type)
== <span style="color: rgb(147, 26, 104);">true</span>)</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">return</span> <span
style="color: rgb(147, 26, 104);">new</span>
Value(value, RU.<span style="color: rgb(0, 39,
204);">SYMBOL</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">else</span> <span
style="color: rgb(147, 26, 104);">if</span> (<span
style="color: rgb(56, 52, 255);">"LONG"</span>.equals(type)
== <span style="color: rgb(147, 26, 104);">true</span>)</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">return</span> <span
style="color: rgb(147, 26, 104);">new</span>
Value(Long.parseLong(value), RU.<span style="color:
rgb(0, 39, 204);">LONG</span>);</div>
<div style="margin: 0px; font: 11px Monaco; color:
rgb(147, 26, 104);"><span style="color: rgb(0, 0,
0);"><span class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span></span>else</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span><span
style="color: rgb(147, 26, 104);">return</span> <span
style="color: rgb(147, 26, 104);">new</span>
Value(value, RU.<span style="color: rgb(0, 39,
204);">ANY</span>);</div>
<div style="margin: 0px; font: 11px Monaco;"><span
class="yiv18163002Apple-tab-span"
style="white-space: pre;"> </span>}</div>
<div>
<div>On Sep 10, 2010, at 11:18 AM, Wolfgang Laun
wrote:</div>
<br class="yiv18163002Apple-interchange-newline">
<blockquote type="cite">So everthing is String or
list of String? (What if your data contains
numbers, where you'd like to use > in
patterns?)<br>
<br>
Is there a stable relationship between key/slot
and its type, i.e., scalar String or list of
String?<br>
<br>
You realize that a record of untyped fields
(slots) is fundamentally different from an
approach where data is bound to be stored in
(necessarily) strongly typed fields of an object.
There's no difficulty with writing similar code
for storing values from a Map into an object of
some class, but class fields must have fixed
types. <br>
<br>
-W<br>
<br>
<br>
<div class="yiv18163002gmail_quote">2010/9/10
Donald Winston <span dir="ltr"><<a
moz-do-not-send="true" rel="nofollow"
ymailto="mailto:satchwinston@yahoo.com"
target="_blank"
href="/mc/compose?to=satchwinston@yahoo.com">satchwinston@yahoo.com</a>></span><br>
<blockquote class="yiv18163002gmail_quote"
style="margin: 0pt 0pt 0pt 0.8ex; border-left:
1px solid rgb(204, 204, 204); padding-left:
1ex;">
<div style="word-wrap: break-word;">This is
what I'm doing:
<div><br>
</div>
<div>
<div style="margin: 0px; color: rgb(78,
144, 114);">/* Assert unordered facts
from the request parameter map. A
deftemplate with matching id and </div>
<div style="margin: 0px; color: rgb(78,
144, 114);"><span style="white-space:
pre-wrap;"> </span> * slots should
already exist. </div>
<div style="margin: 0px; color: rgb(78,
144, 114);"><span style="white-space:
pre-wrap;"> </span> */</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span><span
style="color: rgb(147, 26, 104);">public</span>
<span style="color: rgb(147, 26, 104);">void</span>
assertParameterMap(String id, Map map,
Rete engine) <span style="color:
rgb(147, 26, 104);">throws</span>
JessException {</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>Fact
fact = <span style="color: rgb(147, 26,
104);">new</span> Fact(id, engine);</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>Iterator
keys = map.keySet().iterator();</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span><span
style="color: rgb(147, 26, 104);">while</span>
(keys.hasNext() == <span style="color:
rgb(147, 26, 104);">true</span>) {</div>
<div style="margin: 0px;">
<span style="white-space: pre-wrap;"> </span>String
key = (String)keys.next();</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span><span
style="color: rgb(147, 26, 104);">if</span>
(<span style="color: rgb(0, 39, 204);">ID</span>.equals(key)
== <span style="color: rgb(147, 26,
104);">true</span>) <span
style="color: rgb(147, 26, 104);">continue</span>;</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>String[]
paramValues = (String[])map.get(key);</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span><span
style="color: rgb(147, 26, 104);">if</span>
(paramValues.<span style="color: rgb(0,
39, 204);">length</span> > 1) {</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>ValueVector
values = <span style="color: rgb(147,
26, 104);">new</span> ValueVector();</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span><span
style="color: rgb(147, 26, 104);">for</span>(String
value : paramValues)</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>values.add(<span
style="color: rgb(147, 26, 104);">new</span>
Value(value, RU.<span style="color:
rgb(0, 39, 204);">STRING</span>));</div>
<div style="margin: 0px;">
<span style="white-space: pre-wrap;"> </span>fact.setSlotValue(key,
<span style="color: rgb(147, 26, 104);">new</span>
Value(values, RU.<span style="color:
rgb(0, 39, 204);">LIST</span>));</div>
<div style="margin: 0px;">
<span style="white-space: pre-wrap;"> </span>}</div>
<div style="margin: 0px; color: rgb(147,
26, 104);"><span style="color: rgb(0, 0,
0);"><span style="white-space:
pre-wrap;"> </span></span>else</div>
<div style="margin: 0px;">
<span style="white-space: pre-wrap;"> </span>fact.setSlotValue(key,
<span style="color: rgb(147, 26, 104);">new</span>
Value(paramValues[0], RU.<span
style="color: rgb(0, 39, 204);">STRING</span>));</div>
<div style="margin: 0px;">
<span style="white-space: pre-wrap;"> </span>}</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>engine.assertFact(fact);</div>
<div style="margin: 0px;"><span
style="white-space: pre-wrap;"> </span>}</div>
<div style="margin: 0px;"><br>
</div>
<div style="margin: 0px;">I'm working on
something similar for a jdom document
object. I'm not using POJOs. I'm using a
data structure. (technically they're
objects because java is object oriented,
but they're not "problem domain
objects").</div>
<div>
<div class="yiv18163002h5">
<div style="margin: 0px;"><br>
</div>
<div>
<div>On Sep 10, 2010, at 10:12 AM,
Wolfgang Laun wrote:</div>
<br>
<blockquote type="cite">If you
insert POJOs as facts in Jess,
you'll have to write a <br>
(deftemplace X (declare
(from-class X)))<br>
and the fields available for
pattern matching in rules rely on
the JavaBeans convention.<br>
<br>
I have (quite successfully) used
POJOs resulting from unmarshalling
an XML document (via JAXB) as
facts, both in Drools and in Jess;
most certainly without writing any
"copycat" fact classes and tedious
transformations.<br>
<br>
As for globals: They play the same
role in Drools as in Jess; in
neither system are they part of
the working memory.<br>
<br>
I don't know what you could mean
by a "standard fact class".<br>
<br>
As for iterating over all fact
objects in Drools' WM, Drools
provides getObjects() in
WorkingMemory; or you could set up
a query and run this.<br>
<br>
-W<br>
<br>
<br>
<div
class="yiv18163002gmail_quote">On
10 September 2010 14:54, Donald
Winston <span dir="ltr"><<a
moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:satchwinston@yahoo.com"
target="_blank"
href="/mc/compose?to=satchwinston@yahoo.com">satchwinston@yahoo.com</a>></span>
wrote:<br>
<blockquote
class="yiv18163002gmail_quote"
style="border-left: 1px solid
rgb(204, 204, 204); margin:
0pt 0pt 0pt 0.8ex;
padding-left: 1ex;">
I'm reviewing JBoss Rules
(Drools) for an application
I'm starting to build. It
appears that the only way to
assert facts is to use the
insert(Object) method where
the object is a bean using the
proper naming conventions for
it's properties. There also
appears to be a way to use
arbitrary objects using
globals but do these end up in
the fact base? It's disturbing
to me that I have to create a
bunch of classes whose sole
purpose in life is to support
the rule base. This is similar
to using java server pages and
having to create a bunch of
classes just to support each
page. That's why I don't use
java server pages and use xsl
transformations instead. I
want to use my xml jdom
document to represent my data
and not have to create a bunch
of beans. I can't seem to find
anything in the api where I
can assert facts without
creating my own custom
classes. There's no standard
Fact class?<br>
<br>
I've been also experimenting
with Jess and it provides an
easy way for me to do this. I
just iterate through my jdom
document and create Fact
objects and assert them. I can
then execute the rules and
then iterate through the
updated fact base using
engine.listFacts() and update
my jdom document. It couldn't
be easier or more natural. Is
there an analogous way to do
this in Drools?<br>
<br>
<br>
Thank you very much.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:rules-users@lists.jboss.org"
target="_blank"
href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
rel="nofollow"
target="_blank"
href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
rel="nofollow"
ymailto="mailto:rules-users@lists.jboss.org"
target="_blank"
href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
rel="nofollow" target="_blank"
href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:rules-users@lists.jboss.org"
target="_blank"
href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true" rel="nofollow"
target="_blank"
href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
</blockquote>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true" rel="nofollow"
ymailto="mailto:rules-users@lists.jboss.org"
target="_blank"
href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
</div>
<br>
</div>
<br>
-----Inline Attachment Follows-----<br>
<br>
<div class="plainMail">_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
ymailto="mailto:rules-users@lists.jboss.org"
href="/mc/compose?to=rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div>
</blockquote>
</td>
</tr>
</tbody>
</table>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</body>
</html>