To split the source string you provided you can use a simpler expression:
<xsl:value-of select="replace(item/@effrg, '(.{6}){7}', '$1 $2 $3 $4 $5 $6 $7')" />
in the context where you are running <xsl:analyze-string>
.
With <xsl:analyze-string>
you can get each $n
group with regex-group(n)
. You could then loop in XSLT concatenating the spaces in recursive call-templates.
But you can also loop more concisely in XPath 2.0 using for
and string-join
to obtain the desired result:
<xsl:template match="item">
<xsl:variable name="size" select="floor(string-length(@effrg) div 6)"></xsl:variable>
<xsl:analyze-string regex="(.{{6}}){{{$size}}}" select="@effrg">
<xsl:matching-substring>
<xsl:value-of select="string-join(for $group in 1 to $size return regex-group($group), ' ')"/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>