Used to initiate streamed processing of a source document.
Permitted parent elements: any XSLT element whose content model is sequence constructor; any literal result element
The URI of a source document. It can be written as an attribute value template if the URI is not known statically.
Notes on the Saxon implementation
xsl:stream instruction is new in XSLT 3.0, fully implemented in
Saxon 9.6, and is available in Saxon-EE only (with XSLT 3.0 enabled).
The body of the instruction is a sequence constructor, which is evaluated with the root node of the selected document as the context node. For streaming to work, this must be written as a streamable sequence constructor. Expressed very informally, this means it must only make downward selections in the document, and no instruction or expression may make more than one downward selection. The examples in the W3C specification illustrate some of the possibilities; these examples all work with Saxon.
Some of the things that the instruction might do are:
Compute an aggregate such as a total or average (see the example below).
Initiate processing of the document using template rules, by calling xsl:apply-templates using a streamable mode.
Perform grouping of the document contents using xsl:for-each-group. Saxon only has limited ability to do streamed grouping, but simple cases should work. It is necessary to use one of the attributes
group-ending-with, and to use the new XSLT 3.0 binding variables for current group and current-grouping-key, rather than the XSLT 2.0 function.
For more details on streaming, see Streaming of Large Documents.
A simple example:<xsl:stream href="transactions.xml"> <out><xsl:value-of select="sum(*/transaction/value)"/></out> </xsl:stream>
See further examples in the W3C specification; these examples all work with Saxon 9.5 onwards.