When one calls the normal "assert" function on an object, only that fact is asserted. OBR also allows you to assert an object graph consisting of JAXB objects representing an XML document with the "assertXPath" function. This will assert the tree of objects starting with object passed to the function. The most common path to assert is "//*", meaning the entire subtree, but any arbitrary XPath can be used. assertXPath will assert only objects for which there is a 1-to-many relationship with the parent object. In the JAXB generated code, by default this is represented by a property of List type.
Objects in the hierarchy with a 1-to-1 relationship with their parent can be accessed directly via their parent's property, so it is not necessary to assert them in most cases. This also means that when a schema definition has an object hierarchy with a 1-to-1-to-many relationship, the child and grandchild objects will not be asserted. Some schemas define this type of relationship explicitly, but it can also occur in some situations when anonymous complex types are used.
If the user wishes to have the entire tree below the 1-to-1 relationship asserted, then this tree must be explicitly asserted. One way to do this is to write a rule that will match the parent fact type and call assertXPath with the the child fact type instance as an argument. This rule can then be made to run before all other rules. In the case of invoking a single ruleset from a decision service, this rule should be in the invoked ruleset with a priority higher than all other rules in the ruleset. In the case of invoking a function, the rule should be in a ruleset which is pushed onto the ruleset stack last, so it will be executed first. Because the rule will only match on the fact type, and not any of the properties of the fact type instance, the rule must be written like:
if (fact Parent p && not exists (fact Child c && p.child != c) )
Meaning, the parent exists but the child does not. If only the parent fact is matched, then the rule will re-fire anytime the parent fact is changed, reasserting the child and re-firing any rules which depend on the child. In Rule Author, "not exists" is implemented using the "there is no case where" form of a pattern.
When creating a decision service which invokes a single ruelset, there is a checkbox labeled "Check here to assert all decendants from the top level element". This will cause the decision service to use assertXPath with the path as "//*" instead of the default of only asserting the root object. If you wish to assert something other than "//*" in the decision service, the decisionservice.xml file can be edited to replace "//*" with the desired XPath expression.