So, I am trying to solve a problem in xslt, which I usually know how to do in an imperative language. I add cells to the table from the list of xml elements, standard files. So:
<some-elements> <element>"the"</element> <element>"minds"</element> <element>"of"</element> <element>"Douglas"</element> <element>"Hofstadter"</element> <element>"and"</element> <element>"Luciano"</element> <element>"Berio"</element> </some-elements>
However, I want to cut one line and start a new one after reaching a certain character. Say I allow a maximum of 20 characters per line. I would end up with this:
<table> <tr> <td>"the"</td> <td>"minds"</td> <td>"of"</td> <td>"Douglas"</td> </tr> <tr> <td>"Hofstadter"</td> <td>"and"</td> <td>"Luciano"</td> </tr> <tr> <td>"Berio"</td> </tr> </table>
In an imperative language, I add elements to a string by adding each string-count element to some mutable variable. When this variable exceeded 20, I would stop, build a new line and restart the whole process (starting with the stopped element) in this line after returning the number of lines to zero. However, I cannot change the values โโof variables in XSLT. All this inactivity function, function evaluation function throws me into a cycle.
source share