xsl:number Element
Inserts a formatted number into the result tree.
<xsl:number
level = "single" | "multiple" | "any"
count = pattern
from = pattern
value = number-expression
format = { string }
lang = { nmtoken }
letter-value = { "alphabetic" | "traditional" }
grouping-separator = { char }
grouping-size = { number } />
Attributes
- level
Specifies what levels of the source tree should be considered; it has the values single, multiple or any. The default is single. - count
A pattern that specifies what nodes should be counted at those levels. If the count attribute is not specified, then it defaults to the pattern that matches any node with the same node type as the current node and, if the current node has an expanded-name, with the same expanded-name as the current node. - from
A pattern that specifies where counting starts. - value
Specifies the expression to be converted to a number and output to the result tree. If no value attribute is specified, then the <xsl:number> element inserts a number based on the position of the current node in the source tree. - format
A sequence of tokens that specifies the format to be used for each number in the list. If there are no format tokens, then the default value of 1 is used which generates a sequence 1 2 10 11 12. Each number after the first is separated from the preceding number by the separator token preceding the format token used to format that number. If there are no separator tokens, a period character is used ".".
Format token Sequence generated 1 1 2 3 4 5 10 11 12 01 01 02 03 19 10 11 99 100 101 A A B C Z AA AB AC i i ii iii iv v vi vii viii ix x I I II III IV V VI VII VIII IX X - lang
Specifies which language's alphabet is used. If no lang value is specified, the language is determined from the system environment. - letter-value
Disambiguates between numbering sequences that use letters. One numbering sequence assigns numeric values to letters in alphabetic sequence, and the other assigns numeric values to each letter in some other manner traditional in that language. In English, these correspond to the numbering sequences specified by the format tokens "a" and "i". In some languages, the first member of each sequence is the same, and so the format token alone would be ambiguous. A value of "alphabetic" specifies the alphabetic sequence; a value of "traditional" specifies the other sequence. Default is "alphabetic." - grouping-separator
Gives the separator used as a grouping (for example, thousands) separator in decimal numbering sequences. For example, grouping-separator="," and grouping-size="3" would produce numbers of the form 1,000,000. If only one of the grouping-separator and grouping-size attributes is specified, then it is ignored. - grouping-size
Specifies the size (usually 3) of the grouping. For example, grouping-separator="," and grouping-size="3" would produce numbers of the form 1,000,000. If only one of the grouping-separator and grouping-size attributes is specified, then it is ignored.
Element Information
Number of occurrences | Unlimited |
Parent elements | xsl:copy, xsl:element, xsl:for-each, xsl:if, xsl:otherwise, xsl:param, xsl:template, xsl:variable, xsl:when, xsl:with-param, output elements |
Child elements | (No child elements) |
Remarks
The number to be inserted is specified by an expression contained in the value attribute. The expression is evaluated and the resulting object is converted to a number. The number is rounded to an integer and then converted to a string and inserted in the result tree.
The <xsl:number> element first constructs a list of positive integers using the level, count and from attributes:
- When level="single", it goes up to the first node in the ancestor-or-self axis that matches the count pattern, and constructs a list of length one containing one plus the number of preceding siblings of that ancestor that match the count pattern. If there is no such ancestor, it constructs an empty list. If the from attribute is specified, then the only ancestors that are searched are those that are descendants of the nearest ancestor that matches the from pattern. Preceding-siblings has the same meaning here as with the preceding-sibling axis.
- When level="multiple", it constructs a list of all ancestors of the current node in document order followed by the element itself; it then selects from the list those nodes that match the count pattern; it then maps each node in the list to one plus the number of preceding siblings of that node that match the count pattern. If the from attribute is specified, then the only ancestors that are searched are those that are descendants of the nearest ancestor that matches the from pattern. Preceding siblings has the same meaning here as with the preceding-sibling axis.
- When level="any", it constructs a list of length one containing the number of nodes that match the count pattern and belong to the set containing the current node and all nodes at any level of the document that are before the current node in document order, excluding any name space and attribute nodes (in other words the union of the members of the preceding and ancestor-or-self axes). If the from attribute is specified, then only nodes after the first node before the current node that match the from pattern are considered.
The following languages/numbering schemes are supported. "Format Token" corresponds to the format attribute, "Language" corresponds to the "lang" attribute, and "Letter-Value" corresponds to the letter-value attribute.
Description | Format Token | Language | Letter-Value |
---|---|---|---|
Western | 0x0031 (1) | n/a | n/a |
Upper-case letter | 0x0041 (A) | n/a | n/a |
Lower-case letter | 0x0061 (a) | n/a | n/a |
Upper-case Roman | 0x0049 (I) | n/a | n/a |
Lower-case Roman | 0x0069 (i) | n/a | n/a |
Upper-case Russian (Cyrillic) | 0x0410 | n/a | n/a |
Lower-case Russian (Cyrillic) | 0x0430 | n/a | n/a |
Hebrew Alphabetic | 0x05d0 | n/a | Alphabetic |
Hebrew Traditional | 0x05d0 | n/a | Traditional |
Arabic | 0x0623 | n/a | n/a |
Hindi Consonants | 0x0905 | n/a | n/a |
Hindi Vowels | 0x0915 | n/a | n/a |
Hindi Numbers | 0x0967 | n/a | n/a |
Thai Letters | 0x0e01 | n/a | n/a |
Thai Numbers | 0x0e51 | n/a | n/a |
Japanese Aiueo (double-byte) | 0x30a2 | n/a | n/a |
Japanese Iroha (double-byte) | 0x30a4 | n/a | n/a |
Korean Chosung | 0x3131 | n/a | n/a |
Taiwanese Decimal | 0x4e01 | "zh-tw" | n/a |
Korean Decimal | 0x4e01 | "ko" | n/a |
Far East Decimal | 0x4e01 | any other lang | n/a |
Far East Kanji | 0x58f1 | n/a | n/a |
Traditional Taiwanese | 0x58f9 | "zh-tw" | n/a |
Traditional Chinese | 0x58f9 | any other lang | n/a |
Chinese "Zodiac" 12 | 0x5b50 | n/a | n/a |
Chinese "Zodiac" 10 | 0x7532 | n/a | n/a |
Chinese "Zodiac" 60 | 0x7532, 0x5b50 | n/a | n/a |
Korean Ganada | 0xac00 | n/a | n/a |
Korean Decimal | 0xc77c | n/a | n/a |
Korean 99 | 0xd558 | n/a | n/a |
Western (double-byte) | 0xff11 | n/a | n/a |
Japanese Aiueo (single-byte) | 0xff71 | n/a | n/a |
Japanese Iroha (single-byte) | 0xff72 | n/a | n/a |
If the format token alone is enough to disambiguate a particular numbering scheme, there is no need to specify the language or letter-value.
See Also
Last updated on Saturday, April 10, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.