How to Split a Document based on its size

Hi All,

I have a requirement where I get a Broker Doc. which contains a list of records. Now, I need to create xml records and send to partner. But partner accepts 50 records at a time. So, If I get 100 records in the Broker document, how should I split the document into two xml documents of 50 each.

Please assist. I have no clue.


Loop over the document list.
Append up to 50 to a new list.
Convert to XML or whatever format you need.
Repeat the loop until out of docs

Hi reamon,

Thanks for your reply.

The Broker doc doesn’t contain more than more than 50 records. They can send less than 50 too. If they send more than 50, I need to split them into two.

I am able to do what you have said…like constant for 50 but could you tell if you have any idea for less than 50 scenario.

I am taking if count reaches 50, It will send. But what if there less then 50 transactions. Please let me know what could be the logic…Thanks for your time.


Suppose if you have 125 records in your document, you will send 50 records each 2 times, and then the 25 as the last set. I hope you will not discard the last few records just because it is less than 50. Having said that, if the size of the input document list equals $iteration (which means the last record is reached), convert it to XML String and send.


Hi Senthil,

i have tried the samething…it worked. thanks for your inputs.