Streaming extensions and restrictions

This section describes areas where Saxon differs from the XSLT 3.0 specifications in the constructs that are streamable.

Streaming extensions are enabled only if requested using the configuration option FeatureKeys.STREAMABILITY. The following extensions are offered:

  1. Saxon does not enforce the rule that downward selections are not allowed in crawling posture. This means, for example, that it is OK to use a construct like <xsl:apply-templates select="//title"/>, which is not permitted under the W3C streamability rules because of the possibility that one title will contain another as a descendant. Saxon takes the optimistic view here, and in the event that titles are found at execution time to be nested, it uses some buffering of results to deliver the required output. In such cases the Saxon execution plan is not "pure" streaming, because it uses some memory, but it is very unlikely in most practical cases to cause problems.

  2. Saxon retains a count of the number of preceding siblings (by node name) of streamed elements, both for the currently processed element and for its ancestors. This information allows match patterns such as match="para[1]" to be used in streamable template rules.

Saxon assesses streamability after performing optimization, and this may have the accidental effect of making some constructs streamable that were not streamable as written. The most common cause of this effect is variable and function inlining. The W3C streamability rules do not allow streamed nodes to be bound to variables, or to be passed to or returned from functions, but where the variable or function is inlined, the resulting code may meet all the streamability rules. This effect can occur even if Saxon streaming extensions are not explicitly enabled.

There are also some restrictions in the current implementation of streaming, relative to the W3C specification. These are listed below:

  1. The has-children() function is classified as consuming.

  2. Streamable stylesheet functions are not supported.

  3. Unparsed entities are not available in a streamed document.

  4. Within accumulator rules, it is not possible to make calls on other accumulators.

  5. Within xsl:merge-action, the single-argument form of the function current-merge-group() (which returns a map) is not available. Only the zero-argument form of the function is implemented.

There may be other limitations due to incomplete coverage of the current test suite. These will be documented as they become known.