Expression values
The value to insert can be calculated using an expression, which is entered into the Value attribute. The expression must return a numeric value, as this is used as the count value. The most common expression seen here is simply 'position()'. This function returns the position of the current element from among its siblings:
<number value="position()" format="A"/>
Under most conditions, adopting this approach has no effect on the result, but when the items are also sorted (see Chapter 9), and the final sorted list has to be numbered sequentially, this is the only way to achieve the desired effect. This is due to the fact that the expression is applied to the final, sorted list and not to the items in their original document ...
Get XSL companion, The 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.