If you cannot use database tables then you’ll need some scheme that writes records temporarily to different temporary files.
Probably a way to figure out how to best do this without loading the entire file into memory is to think about how you’d do this if you were coding it all in Java. Then take a similar approach but use IS services and techniques for the different parts.
If the file (and it’s processing) fits into memory I would use an XSLT service, as XSLT provides grouping of elements. XSLT is also a good alternative if you have greater changes in the structure which are difficult to implement using map steps like movmeent of nodes in the document hierarchy, changes of grouoings etc.