Possibly an excercise in the ridiculous - but I am stumped by what I thought would be rather simple: using XSLT to partition a large log file (20mb) into multiple smaller files (4mb).

Here is what I have:

   <xsl:variable name="input" select="unparsed-text('ServerLog.csv')"/>
   <xsl:template match="/">
           <xsl:for-each-group select="tokenize($input, '\n')" group-by="position() mod 2000 = 0">
                   <xsl:for-each select="current-group()">
                       <xsl:element name="row">
                           <xsl:sequence select="."/>

Multiple outputs aside for the moment, I find myself challenged just to get the grouping of a sequence. The above runs but does not partition into groups of 2000.

Alternatively, I had been thinking the group-by would be something like:

group-by=". | following-sibling::node()[position() &lt; 2000]"
But Oxygen complains that [Saxon-PE] Required item type of first operand of '|' is node(); supplied value has item type xs:string.

Forgive my obsession with the trivial, but I at least for the sake of my own education I can't let this go ;)

All feedback welcome,