diff --git a/specifications/xslt-40/src/element-catalog.xml b/specifications/xslt-40/src/element-catalog.xml
index 9a4603ae4..0131fe55b 100644
--- a/specifications/xslt-40/src/element-catalog.xml
+++ b/specifications/xslt-40/src/element-catalog.xml
@@ -1654,6 +1654,9 @@
An
The capture
attribute is allowed only on an phase="end"
. Its effect is described in
as
attribute defaults to item()*
.
- The effect of the streamable
attribute is defined in
The effect of the streamable
+ capture
select
expression or contained sequence
constructor.
+ There is a slight variation here for an accumulator rule specifying
+ phase="end"
and capture="yes"
. For details,
+ see
The capture
attribute is intended primarily for use with streamable accumulators, but
+ in the interests of consistency, it has the same effect both for streamable and non-streamable
+ accumulators. If an accumulator rule with phase="end"
specifies capture="yes"
,
+ then the rule is evaluated not with the matched node as the context item, but rather with a snapshot
+ copy of the matched node. The snapshot copy is made following the rules of the
The principal effect of specifying capture="yes"
is to relax
+ the rules for streamability. With this option, the phase="end"
accumulator rule
+ has access to the full subtree rooted at the node being visited. In a typical implementation,
+ a streaming processor encountering an element that matches a capturing accumulator rule
+ will make an on-the-fly in-memory copy of that element, allowing the phase="end"
+ accumulator rule full access to the subtree, and also to attributes of ancestors.
This means that an accumulator that needs access to the typed value or string value of an element + can get this directly with a rule that matches the element, avoiding the need + to write rules that match the element’s text node children. +
+ +For example, to capture a copy of the most recent h2
element in a document,
+ the following accumulator might be declared:
and subsequent processing wishing to copy the most recent h2
element into the result
+ tree can simply use <xsl:copy-of select="accumulator-before('most-recent-h2')"/>
.
Without the capture="yes"
attribute, this accumulator would be rejected
+ as non-streamable, because the select
expression on the accumulator rule
+ is consuming.
Suppose a document contains definitions of technical terms with markup such as:
+and the requirement is to generate a glossary that lists all the defined terms in the document, as an appendix.
+This can be achieved by capturing all the defined terms in a map:
+Suppose that the input XML document contains an element <glossary/>
marking
+ the point where the glossary is to be inserted. The glossary can then be generated
+ using a template rule such as:
An accumulator is
The select
attribute or contained
- sequence constructor is
phase="start"
(the default value),select
attribute or the contained
+
In an phase="end"
, one of the
+ following conditions holds:
The rule has capture="no"
(the default value),
+ and the select
attribute or the contained
+
The rule has capture="yes"
and the select
attribute or the contained
+
Simplified stylesheets no longer require an xsl:version
attribute
(which means they might not need a declaration of the XSLT namespace). Unless otherwise
specified, a 4.0 simplified stylesheet defaults expand-text
to true
.
A new set of built-in template rules is introduced, invoked using
<xsl:mode on-no-match="shallow-copy-all">
. This is designed to allow rule-based recursive
transformation of JSON data structures (trees of maps and arrays) to work in the same way as with
XML-derived data structures.
The streamability rules for accumulators have been relaxed, so that the phase="end"
+ processing has access to the full subtree of the matched node.