I'm trying to create what I think should be a relatively simple business rule to operate over repeating elements in an XML schema.
Consider the following XML snippet (this is simplified with namespaces removed, for readability):
<Root>
<AllAccounts>
<Account id="1" currentPayment="10.00" arrearsAmount="25.00">
<AllCustomers>
<Customer id="20" primary="true" canSelfServe="false" />
<开发者_如何学PythonCustomer id="21" primary="false" canSelfServe="false" />
</AllCustomers>
</Account>
<Account id="2" currentPayment="10.00" arrearsAmount="15.00">
<AllCustomers>
<Customer id="30" primary="true" canSelfServe="false" />
<Customer id="31" primary="false" canSelfServe="false" />
</AllCustomers>
</AllAccounts>
</Root>
What I want to do is to have two rules:
- Set /Root/AllAccounts/Account[x]/AllCustomers/Customer[primary='true']/canSelfServe = true IF arrearsAmount < currentPayment
- Set /Root/AllAccounts/Account[x]/AllCustoemrs/Customer[primary='true']/canSelfServer = false IF arrearsAmount >= currentPayment
Where [x] is 0...number of /Root/AllAccounts/Account records present in the XML.
I've tried two simple rules for this, and each rule seems to fire x * x times, where x is the number of Account records in the XML. I only want each rule to fire once for each Account record.
Any help greatly appreciated!
Thanks
Andrew
Make sure that the rules have the same Priority, just in case (I had issues with priorities before). I've also saw that at the Rules level, there is a property called maximum Execution Loop Depth, which assigns how many times can a rule be reevaluated. Try to put 1 there, if you're sure that your rules should only be evaluated once per payload. I hope this helps.
Check your predicate. The rule fires once for each matching combo of fields used in the predicate.
精彩评论