XSLT 3.0 for-each-group select="copy-of(foo)" group-starting-with="foo[bar = ...]" with multiple use of current-group() does not pass the streamability analysis
Added by Martin Honnen about 8 years ago
I have run into a problem with the streamability analysis of some code with @for-each-group@ where the grouping population is created using @copy-of(foo)@ (which I had to do as the pattern in @group-starting-with@ is not motionless) and where inside of the @for-each-group@ I try to repeatedly access @current-group()@.
The sample stylesheet is
When I try to run that with Saxon-EE 9.7.0.8J from the command line the output is
Static error at xsl:template on line 14 column 30 of test201610160103.xsl: XTSE3430: Template rule is declared streamable but it does not satisfy the streamability rules. * The current-group() function is evaluated repeatedly * Predicate at line 20 is not motionless
Obviously there are several uses of @current-group()@ inside of the @for-each-group@ and the predicate @current-group()[1]/th[@scope = 'rowgroup']@ is not motionless but I am astonished that this matters given that the grouping population is created with @copy-of(tr)@ so that the body of the @for-each-group@ does not process any streamed nodes. Is Saxon rightly rejecting the code as not streamable given that the grouping population is created using @copy-of(tr)@?
Exselt happily compiles and runs the code without complaining about streamability but on the other hand it even does that when I simply use @<xsl:for-each-group select="tr" group-starting-with="tr[th[@scope = 'rowgroup']]">@ so I am not sure how meaningful Exselt's streamability analysis is.
An input sample is
2005DEC
Blemish on Card
Damaged
2006JAN
Lost
Stolen
Replies (3)
Please register to reply
RE: XSLT 3.0 for-each-group select="copy-of(foo)" group-starting-with="foo[bar = ...]" with multiple use of current-group() does not pass the streamability analysis - Added by Michael Kay about 8 years ago
In my current working version, this is passing streamability analysis but giving what appears to be incorrect results:
2005 DEC Blemish on Card Damaged 2006 JAN Lost Stolen
RE: XSLT 3.0 for-each-group select="copy-of(foo)" group-starting-with="foo[bar = ...]" with multiple use of current-group() does not pass the streamability analysis - Added by Michael Kay about 8 years ago
Seems to be caused by the rewrite of current-group()[1] as ".", introduced for bug 2972. This rewrite is incorrect when doing
... select="current-group()[1] "...
But after removing this rewrite, we get the original error reported:
XTSE3430: Template rule is declared streamable but it does not satisfy the streamability rules. * The current-group() function is evaluated repeatedly
Please register to reply