Since DataPower XSLT processor does not provide tail-recursion optimization use of divide-and-conquer technique is required.This recursive function runs out of stack space because a 4MB string results in more than 50.000 lines -- too much for recursion call-depth.

This is the devide-and-conquer technique which solves the problem easily -- determine $mid as offset where to split, "near" the middle (multiple of 76):

What can be learned from this?Always implement "little helper functions" as efficient as possible -- you never know how others make use of them ... :-)