Displays a number. It is most often used to number parts of a document, although it can also be used to format a numeric value.



Required Attributes


Optional Attributes


The count attribute is an XPath pattern that defines what should be counted. If the count attribute isn’t specified, it counts nodes with the same name as the current node.


This attribute defines what levels of the source tree should be considered when numbering elements. The three valid values for this attribute are single, multiple, and any:


Counts items at one level only. The XSLT processor goes to the first node in the ancestor-or-self axis that matches the count attribute, and then counts that node plus all its preceding siblings that also match the count attribute. This is the default value.


Counts items at multiple levels. The XSLT processor looks at all the ancestors of the current node and at the current node itself, and then it selects all nodes that match the count attribute.


Includes all of the current node’s ancestors (as level="multiple" does) as well as all elements in the preceding axis.

In all of these cases, if the from attribute is used, the only ancestors that are examined are descendants of the nearest ancestor that matches the from attribute. In other words, with from="h1", the only nodes considered for counting are those that appear under the nearest <h1> attribute.


The from attribute is an XPath pattern that defines where counting ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.