saxon:capture
This attribute may be set on an xsl:accumulator-rule element. It has no effect
unless the accumulator is declared streamable and the rule has phase="end"
. It is intended
for use when the accumulator rule matches an element node. The value
is a boolean with the default "no".
The effect of setting this attribute is that the code for computing the new accumulator value when the element end tag is encountered now has access to a snapshot copy of the matched element (as if taken using the fn:snapshot function), and is no longer required to be motionless.
This means that if you want access to the typed value or string value of an element, you can now get this directly with a rule that matches the element, rather than having to write rules that match the element's text node children.
It also opens up additional possibilities. For example:
- If a large document has a short header section containing metadata, you can capture a copy of the header in an accumulator, and the header then becomes available throughout the rest of the document processing using the accumulator-after() function.
- If you want to produce a sorted index of terms that are marked up using
glossary
elements scattered throughout the document, you can define an accumulator that retains snapshot copies of all theglossary
entries (useselect="($value, .)"
in the accumulator rule). At the end of processing, you can sort and group these glossary entries, and because they are snapshot copies retaining all the attributes of ancestors, you can link them to theid
anchors of the containing sections.