<!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">
Hi Wolfgang,<br>
<br>
Thanks for the helpful response.<br>
<br>
I do find myself using "contains" and "memberof" quite a lot
depending on whether I am going "up" or "down" the tree structure.
Is this a performance problem? Is it better to use "from"?<br>
Thanks for the hint about adding the "parent" pointer in the child.
I'll have to think about that one because the schema is actually
shared with external trading partners.<br>
I guess I could have an "external" version and and "internal"
version but then I would have 2 versions to maintain and that is not
very desirable.<br>
As someone else has asked, I do actually make modifications to the
model that I want to return to the client. So it is not read-only.
That means I would then have to do a post-rule processing pass to
null out the parent pointers (otherwise I would have cycles in the
graph!) before returning the answer. Actually... @XmlTransient will
probably have the desired effect.<br>
<br>
(Thinks: I wonder whether it would be possible to write a JAXB
plugin to do this stuff and make the generated classes more
"rules-friendly")<br>
<br>
Thanks also for the hint about the code injection plugin. I was not
aware of that. I have just done some investigation into that and I
find that the code-injection plugin is present in my Glassfish
server but is not named in the
META-INF/services/com.sun.tools.xjc.Plugin file. So I'm not sure
that I can use it without getting a separate installation of JAXB.<br>
<br>
Chris<br>
<br>
<br>
On 28/11/2010 13:12, Wolfgang Laun wrote:
<blockquote
cite="mid:AANLkTinL_rTXxp2GHjX7VcZJOic+9H6G2_tN5gJLXgFg@mail.gmail.com"
type="cite">An XML schema just fitting your XML data will
frequently not result in a class<br>
hierarchy that's well suited for writing rules.<br>
<br>
One point deals with representing the parent-child relationship,
especially<br>
when there are multiple children of a kind, i.e., the parent class
contains a<br>
List<?>. You have this in XML the natural way; you lose it
when you just<br>
insert parents and children. If extending the XML schema is
possible, you<br>
can add another element with minOccurs="0" to the Child
complexType of<br>
type Parent and set the reference to the current parent when you
walk the<br>
object tree. (You can erase the List<?> in the parent.) This
avoids the<br>
frequent use of the "from" clause in conditions.<br>
<br>
You may also have to handle repeated occurrences of elements that
are<br>
"equal" as objects but appear in full XML text; this is usually
simple to handle<br>
with a temporary Set, but you'll have to add hashCode and equals
to the<br>
JAXB generated classes using the code injection plugin.<br>
<br>
Inserting just the root element is not advisable, as you are well
aware of.<br>
<br>
-W<br>
<br>
<br>
<br>
<div class="gmail_quote">On 28 November 2010 12:38, Chris Selwyn <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:chris@selwyn-family.me.uk">chris@selwyn-family.me.uk</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 am working on a project that is using Drools to
perform validation of<br>
hierarchical XML messages.<br>
<br>
So I have passed the XSDs through JAXB and have a set of
interrelated<br>
Java objects.<br>
One of these objects (naturally) represents the root of the
messages and<br>
the others represent the intermediate and leaf nodes of the
message.<br>
<br>
My question is: Should I traverse the tree and insert each
object into<br>
the working memory or should I just insert the root object
into the<br>
working memory?<br>
<br>
If I insert each object into the memory then I have a lot of
flexibility<br>
about how I write my rules... I can start by focussing on the
particular<br>
part of the message that I want to detect an error in.<br>
However, I then have to perform a whole bunch of "joining"
clauses to<br>
correctly "connect up" to the other objects in the working
memory.<br>
(This is how I am doing it at the moment... I have a mechanism
that uses<br>
the Java Introspector. It identifies by package name which
parts of the<br>
data model get inserted into the WM)<br>
<br>
On the other hand, I could just insert the root object into
the WM. This<br>
means that I would have to write really complicated where
clauses on the<br>
root object but very much simplifies the WM loading process.<br>
<br>
All of the examples that I have seen have a very simple flat<br>
(non-hierarchical) structure that don't really give a hint as
to what a<br>
"best practice" might be.<br>
<br>
Any suggestions/insights welcome :-)<br>
<font color="#888888"><br>
Chris Selwyn<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="mailto: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>
</font></blockquote>
</div>
<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>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<p class="avgcert" color="#000000" align="left">No virus found in
this message.<br>
Checked by AVG - <a moz-do-not-send="true"
href="http://www.avg.com">www.avg.com</a><br>
Version: 10.0.1170 / Virus Database: 426/3284 - Release Date:
11/27/10</p>
</blockquote>
</body>
</html>