BizTalk Business Rules Engine - Repeating Elements Question

Posted by Andrew Cripps on Stack Overflow See other posts from Stack Overflow or by Andrew Cripps
Published on 2010-02-10T15:11:23Z Indexed on 2010/03/18 2:11 UTC
Read the original article Hit count: 431

Filed under:
|

Hello

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" />
        <Customer 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

© Stack Overflow or respective owner

Related posts about BizTalk

Related posts about business-rules