Numbering

The <xsl:number> element performs two functions:

  1. It evaluates a numeric expression and converts the result into a formatted string:

    <xsl:number value="3" format="A. "/>
    <xsl:number value="count(listitem)" format="01"/>
  2. It counts elements in the source tree and converst the result into a formatted string:

    <xsl:number count="listitem" format="i. "/>
    <xsl:number count="chapter" from="book" level="any" format="1. "/>
    <xsl:number count="h1|h2|h3" level="multiple" from="chapter|appendix" format="1."/>

The details of number to string conversion is spelled out in great detail in Section 7.7.1 (http://www.w3.org/TR/xslt.html#convert) of the XSLT Recommendation (http://www.w3.org/TR/xslt.html). See also, <xsl:decimal-format> and the Java JDK 1.1 DecimalFormat (http://java.sun.com/products/jdk/1.1/docs/api/java.text.DecimalFormat.html) class.