The current-group () function returns the set of items making up the group that is currently being processed using the <xsl:for-each-group> instruction.
This function is new in XSLT 2.0.
There are no arguments.
Data type | Meaning | |
---|---|---|
Result | item()* | A sequence of items, specifically the sequence that is being processed in the current iteration of an <xsl:for-each-group> instruction. |
When the stylesheet starts executing, there is no current group; the current-group() function then returns an empty sequence.
The <xsl:for-each-group> instruction, described in Chapter 5, page 281, takes as input a sequence of items (called the population) and a grouping expression or pattern. It allocates each item in the population to zero or more groups of items, and then processes each group in turn . While it is processing each group, the current-group() function returns the sequence of items that participate in that group.
The current-group() function does not need to be called textually within the <xsl:for-each-group> instruction. Its scope is dynamic, and the current group remains available in called templates unless another nested <xsl:for-each-group> instruction is evaluated. On completion of an <xsl:for-each-group> instruction, it reverts to its previous value.
The current-group() function can also be called while evaluating the sort key in an <xsl:sort> element contained within the <xsl:for-each-group> instruction. This affects the order in which groups are processed. In this context, current-group() refers to the group whose sort key is being calculated. For example, to sort groups in order of decreasing size , write <xsl:sort select= "count (current-group())" order="descending"/> .
On entry to a stylesheet function, the current group is an empty sequence.
See <xsl:for-each-group> on page 281 in Chapter 5.
<xsl:for-each-group> on page 281 in Chapter 5.
current-grouping-key () -the next entry in this chapter.