<xsl:variable name="string" select="'abcdefghijklmnopqrstuvwxyz'" />
I would need to convert this string to a node, grouped by 5 characters, obviously the last group can be less than or equal to 5 characters depending on the input string
<node>
<a>abcde</a>
<a>fghij</a>
<a>klmno</a>
<a>pqrst</a>
<a>uvwxy</a>
<a>z</a>
</node>
This transformation:
when applied on any XML document (not used), produces the wanted, correct result:
Explanation: Primitive recursion with no string length as the stop condition, and with each recursion step producing the next chunk and cutting it from the string.