I'm currently working on a solution that is similar to what you
describe.

I have an (almost completely flat) XML file generated by a 3rd party
product.  I apply an XSLT script which generates (fact) statements based
on the 3rd party XML file's contents.  I then load the (fact) statements
into working memory.  My ruleset 'reasons' against the facts in working
memory and constructs a hierarchy of (shadow) facts.  I previously
persisted the resultant object graph directly to our RDBMS using
Hibernate.  I've since modified this approach to write out a reasonably
nested XML document instead (using JDom).  I then use the Jakarta
Commons Digester to load the generated XML file into the RDMS for
subsequent processing (this approach enabled me to use XMLDiff for
regression testing).

Obviously, in order to use facts to represent hierarchy, you need to
either have (parent) facts hold references to (fact IDs of) other
(child) facts, or use some other relational trick.  For example, while
interpreting tabular data, I have rules that create a (DetailRow) fact
for every row of source data.  I assign a 'row' slot to preserve
document order.  For each column, I create an (Column) fact with a
'rowId' slot that references the containing (DetailRow) fact.  Each
(Column) fact has a 'position' slot that maintains the column order.

Now that I have deduced (DetailRow) and (Column) facts, and the
relationships between them, I can write rules that apply reasoning to
the table contents (i.e. business rules).

Once all business rules have been processed, I emit a heirarchical XML
structure containing the processed data that looks something like this:

<Document format="tabular">
  <DetailRow row="1">
    <Column type="ssn">123456789</Column>
    <Column type="amount>123.45</Column>
    ...
  </DetailRow>
</Document>

The bottom line is that constructing and manipulating hierarchical data
is not necessarily intuitive, but not necessarily difficult either.

-Mitch

PS I don't present this information with the belief that what I'm doing
is necessarily correct, but rather with the hope that if I'm doing
something wrong, someone will hopefully say something. ;)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Srini
Sent: Tuesday, November 02, 2004 3:15 PM
To: [EMAIL PROTECTED]
Subject: JESS: Rules for Java Bean Tree built from XML


Hi,
  I have an complex java bean tree where a parent bean has a collection
of children beans and in turn the child bean has a reference to the
parent bean. This bean tree is created when paring an XML. Now this bean
tree has to be validated against some business rules which requires to
traverse up and down the tree. Now my question is

1. how write rules for such a scenario? 
2. Should the tree be pushed on the Jess when the tree is being build or
just push the root of the tree.

Please help out if there any examples for such scenarios? 

Srini


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use
your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------



--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to