Name

[2.0] <xsl:for-each-group>

Takes the items in a sequence and puts them into groups. There are four different ways of defining groups, each of which are explained in detail below. The grouping is done based on a common value or by a pattern that the first or last item in the group must match. Be aware that it is possible for an item in the original sequence to be put into more than one group.

Category

Instruction.

Required Attribute

select

An XPath expression that determines the items to be grouped.

Optional Attributes

group-by

Defines a common value that all items in a group must share. For example, group-by="state" creates a group for each unique value of the <state> element. All items in a given group will have the same value for <state>.

group-adjacent

Defines an expression that is evaluated for every item in the sequence. If the value of that expression for the current item is the same as the value of that expression for the previous item, then the current item is put into the same group as the previous item. If not, the current item becomes the first item in a new group.

group-starting-with

Defines a pattern that indicates the start of a new group. When an item matching that pattern is found, a new group is started, and all subsequent items are put into the same group until another item that matches the pattern is found.

group-ending-with

Defines a pattern that indicates the end of the current group. When an item matching that pattern is found, the current group is closed. The next item ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.