xsl:number
<xsl:number value = "number-expression
" count = "pattern
" from = "pattern
" level = "single" | "multiple" | "any" format = "letter or digit
" lang = "langcode
" letter-value = "alphabetic" | "traditional" grouping-separator = "char
" grouping-size = "number
" />
The xsl:number
instruction inserts a formatted integer into the result
tree.
value
,
optionalThis XPath expression returns the number to be
formatted. If necessary, the result of the expression is
rounded to the nearest integer. The value
attribute is often omitted,
in which case the number is calculated from the position of
the current node in the source document. The position is
calculated as specified by the level
, count
, and from
attributes.
count
,
optionalThis attribute contains a pattern that specifies which nodes should be counted at those levels. The default is to count all nodes with the same node type (element, text, attribute, etc.) and name as the current node.
from
, optionalThis attribute contains a pattern identifying the node
from which counting starts; that is, it identifies a node
that serves as a cutoff point. Any nodes that precede this
node are not counted, even if they match the count
pattern.
level
,
optionalThis attribute specifies which levels of the source
tree should be considered in determining the position of the
current node. It can be set to single
to count the preceding
siblings of the current node's ancestor that match the
count
pattern. It can be
set to any
to count all
nodes in the document that match the count
pattern and precede the
current node. It can be set to multiple
to produce hierarchical
sequences of numbers such as 2.7.3, where each number in the
sequence is calculated from the preceding sibling's ancestor
node that matches the count
pattern. The default is
single
.
format
, optional,
attribute value templateThis attribute determines how the list is numbered. Format tokens and sequences they produce include the following:
1, 2, 3, 4, 5, 6, . . .
01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, . . .
A, B, C, D, . . . , Z, AA, AB, AC, . . .
a, b, c, d, . . . , z, aa, ab, ac, . . .
i, ii, iii, iv, v, vi, vii, viii, ix, x, xi, . . .
I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, . . .
lang
, optional,
attribute value templateThis is the RFC 1766 language code describing the
language in which the number should be formatted (e.g.,
en
or fr-CA
).
letter-value
,
optional, attribute value templateThe default is traditional
. However, you can set
this attribute to alphabetic
to indicate that a
format
of I
should start the sequence I, J,
K, L, M, N, . . . rather than I, II, III, IV, V, VI, . .
.
grouping-separator
,
optional, attribute value templateThis is the character that separates groups of digits. For instance, in English, the comma customarily separates every three digits, as in 2,987,667,342. In French, a space is used instead, so this number would be formatted as 2 987 667 342.
grouping-size
,
optional, attribute value templateThis is the number of digits in each group. In most languages, including English, digits are divided into groups of three. However, a few languages use groups of four.