xsl:accumulator-rule¶
Defines a rule for an xsl:accumulator
.
Available in XSLT 3.0. From Saxon 9.8, available in all editions. Implemented in Saxon-PE and Saxon-EE since Saxon 9.6.
- Content: sequence-constructor
- Permitted parent elements:
xsl:accumulator
Attributes¶
match
- pattern
- Pattern defining the set of nodes to which the accumulator rule applies.
phase?
"start" | "end"
- Determines whether the rule fires before or after descendants are processed, by specifying
phase="start"
(the default) orphase="end"
respectively. select?
- expression
- The expression to be evaluated by the rule may be given either by a select attribute, or by an enclosed sequence constructor.
saxon:capture?
- boolean
- The value
"yes|true|1"
on aphase="end"
rule for a streaming accumulator removes the requirement for the select attribute (or sequence constructor) to be motionless. Instead the expression has access to a snapshot of the streamed node (in the sense of thefn:snapshot
function). For example, writingselect="($value, .)"
ensures that the value of the accumulator contains a sequence of snapshot copies of all the element nodes matched by the accumulator rule. For details seesaxon:capture
.
Examples¶
For an example of the use of a capturing accumulator rule to construct the glossary of a document, see the blog article Capturing Accumulators.
Example¶
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Declare accumulator for calculating minimum salary -->
<xsl:accumulator name="min-salary" initial-value="10000000">
<!-- Define rule for employee elements -->
<xsl:accumulator-rule match="employee" select="if (@salary lt $value) then @salary else $value"/>
</xsl:accumulator>
<!-- The rest of the style -->
</xsl:stylesheet>