You'll also have to learn about handling XML with Java, e.g., using JAXB, which
comes with JDK.

Given that you have an XML document, unmarshalling creates,
from the XML file, a hierarchy of objects. Usually they are are already linked in
some way, depending on the way the XML schema is structured. (Typically, a
parent node contains a List of its children.) Then, you walk the document tree,
inserting some or all of the objects into Working Memory. After firing the rules,
you simply marshal the document, starting at the root node to create the output
XML.

-W

On 30 July 2012 20:51, BenjaminWolfe <benjamin.e.wolfe@gmail.com> wrote:
I'm learning Java and Drools at the same time; please be gentle if my
question is misdirected.

I'm working on creating my first nontrivial fact model.  A policy can have
multiple vehicles; a vehicle can have multiple coverages.  My data will come
into the rules engine via an XML file, and be output to XML after all rules
are fired.  I'm looking for best practices.

I've seen it suggested to use a relational approach to my object graph.  A
policy will have policyID 12345; its vehicles will have a policyID field,
and each will have a different vehicleNumber (e.g. 1, 2 and 3).  A coverage
will have policyID (12345) and vehicleNumber(1), and a coverage identifier
of its own.

That seems simple, sleek and elegant.  I hope to use it to write rules.  But
I wonder if it will be resource-intensive when I get to outputting the XML.
I'm imagining having to write the policy node, then search all vehicles for
the 3 that are related to this policy, then search through all coverages for
the ones corresponding to each vehicle, etc.

Is it better to include some sort of collection?  (Policy 12345 might
include a collection of vehicles, each of which would include a collection
of coverages.)  If so, what kind of collection: an implementation of set?
list? map?  More specifically, are there drawbacks or advantages to one
approach or another?

I'm very thankful for any guidance you'd like to offer.

Best regards,
Benjamin



--
View this message in context: http://drools.46999.n3.nabble.com/Collections-versus-Relational-Approach-in-Fact-Model-tp4018965.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users