Logged as a bug here:
https://saxonica.plan.io/issues/2292
and I've added the test case to the W3C test suite (assuming your consent...)
You're quite right that this isn't streamable according to the W3C rules, and
Saxon should report a compile-time error.
Streamed grouping has been one of the toughest things to make work, both in
Saxon and in the W3C spec. In fact, while Saxon 9.6 generally uses
streamability rules that are now quite closely aligned with the W3C spec, this
isn't yet the case for grouping, partly because we've been finding bugs in both.
Saxon's streaming strategy is generally:
(1) test the code statically against the W3C streamability rules.
(2) generate code for streamed execution
(3) execute that code
In principle, if we do (1) correctly, then failures should never occur at
stages (2) or (3). In practice, a failure sometimes occurs at stage (2) because
there are things W3C allows that Saxon does not yet implement; and a failure
sometimes occurs at stage (3) simply because with streaming, there are an awful
lot of things that can go wrong and we still only have a couple of thousand
test cases.
Michael Kay
Saxonica
mike(_at_)saxonica(_dot_)com
+44 (0) 118 946 5893
On 17 Jan 2015, at 10:35, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
I am trying to explore the use of streaming with various grouping approaches,
mainly with Saxon 9.6 EE, but for comparison I also run examples through the
online version of Exselt http://exselt.net/demo.
So far, when I used <xsl:mode streamable="yes"/> to make the whole code use
streaming Saxon threw an error on stylesheet compilation if a construct or
expression breaking streamability rules was used (for instance "The
group-adjacent expression is not motionless").
However with a test case using
group-starting-with="record[foo = 'a']"
Saxon does compile the stylesheet but then gives various warnings during the
execution that " SXST0061: An error occurred matching pattern {record[foo =
'a']}: Navigation using child axis is not supported from a streamed input
node". and produces a wrong transformation result.
I understand the problem with that pattern and the "foo" child axis access
but I wonder whether it should be found as an error during compilation, as in
the other examples I tried.
Exselt does run the stylesheet and produces the wanted result but I have no
way of seeing whether it built a tree or not.
Here are the samples, the stylesheet is
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:mode streamable="yes"/>
<xsl:output indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="record" group-starting-with="record[foo =
'a']">
<group>
<xsl:copy-of select="current-group()"/>
</group>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
an input sample is
<root>
<record>
<foo>a</foo>
<bar>1</bar>
</record>
<record>
<foo>b</foo>
<bar>2</bar>
</record>
<record>
<foo>a</foo>
<bar>3</bar>
</record>
<record>
<foo>b</foo>
<bar>4</bar>
</record>
<record>
<foo>a</foo>
<bar>5</bar>
</record>
<record>
<foo>a</foo>
<bar>6</bar>
</record>
<record>
<foo>c</foo>
<bar>7</bar>
</record>
</root>
the output I want is
<root>
<group>
<record>
<foo>a</foo>
<bar>1</bar>
</record>
<record>
<foo>b</foo>
<bar>2</bar>
</record>
</group>
<group>
<record>
<foo>a</foo>
<bar>3</bar>
</record>
<record>
<foo>b</foo>
<bar>4</bar>
</record>
</group>
<group>
<record>
<foo>a</foo>
<bar>5</bar>
</record>
</group>
<group>
<record>
<foo>a</foo>
<bar>6</bar>
</record>
<record>
<foo>c</foo>
<bar>7</bar>
</record>
</group>
</root>
the one Saxon 9.6 EE gives is
<root>
<group>
<record>
<foo>a</foo>
<bar>1</bar>
</record>
<record>
<foo>b</foo>
<bar>2</bar>
</record>
<record>
<foo>a</foo>
<bar>3</bar>
</record>
<record>
<foo>b</foo>
<bar>4</bar>
</record>
<record>
<foo>a</foo>
<bar>5</bar>
</record>
<record>
<foo>a</foo>
<bar>6</bar>
</record>
<record>
<foo>c</foo>
<bar>7</bar>
</record>
</group>
</root>
but as I said, with various warnings that something went wrong, of the form
Warning: on line 11 of test2015011607.xsl:
SXST0061: An error occurred matching pattern {record[foo = 'a']}: Navigation
using child axis is not supported from a streamed input node
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--