I have an XML with a text node, and I need to split this string into multiple chunks using XSLT 2.0. For example:
<tag>
<text>This is a long string 1This is a long string 2This is a long string 3This is a long string 4</text>
</tag>
The output should be:
<tag>
<text>This is a long string 1</text>
<text>This is a long string 2</text>
<text>This is a long string 3</text>
<text>This is a long string 4</text>
</tag>
Note that I deliberately set the chunk size to the length of each statement so that the example is easier to read and write, but the transformation should accept any value (it is okay for this value to be hardcoded).
This XSLT 1.0 transformation:
when applied on the provided XML document:
produces the wanted, correct result:
II. XSLT 2.0 solution (non-recursive):