xsl:number

Inserts a formatted number into the result tree.

Format

<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}]/> 
               

            

Description

You can use the value attribute to specify an expression for the number to be inserted. The XSLT processor evaluates the expression. The resulting object is converted to a number as if by a call to the number() function. The processor rounds the number to an integer and then uses the specified attributes to convert it to a string. The value of each attribute is interpreted as an attribute value template. After conversion, the resulting string is inserted in the result tree.

The following attributes control how the current node is to be numbered:

  • The level attribute specifies what levels of the source tree should be considered. The default is single.
  • The count attribute is a pattern that specifies what nodes should be counted at those levels.
  • The from attribute is a pattern that specifies where counting starts.
  • The value attribute can specify an expression that represents the number you want to insert. If no value attribute is specified, the XSLT processor inserts a number based on the position of the current node in the source tree.
  • The format attribute specifies the format for each number in the list. The default is 1.
  • The lang attribute specifies which language's alphabet is to be used.
  • The letter-value attribute distinguishes between the numbering sequences that use letters.
  • The grouping-separator attribute specifies the separator used as a grouping (for example, thousands) separator in decimal numbering sequences.
  • The grouping-size attribute specifies the size of the grouping. Normally, this is 3.

Example

The following example numbers a sorted list:

<xsl:template match="items">
               
  <xsl:for-each select="item">
               
    <xsl:sort select="."/>
               
<p>
               
  <xsl:number value="position()" format="1. "/>
               
  <xsl:value-of select="."/>
               
</p>
               
  </xsl:for-each>
               
</xsl:template>
               

            

Whitepaper: FIXML - Working with Complex Message Sets Defined Using XML Schema

The advanced XML Schema handling and presentation capabilities of Stylus Studio have valuable implications for users of industry-specific XML message sets.

XQuery API for Java (XQJ)

DataDirect XQuery is an embeddable software product based on the XQuery and XQJ standards that enables Java developers to access both relational and XML data sources using a single XQuery query. Runs on Oracle, SQL Server, DB2, and more!

The Java Architecture for XML Binding (JAXB)

In this JAXB tutorial, we'll show you how easy it is to generate JAXB bindings!

XML Well-Formedness Checker & XML Indenter

Tidy up your XML documents with powerful integrated XML editing utilities including a single-click XML formatter, pretty printer, XML indenter and XML well formedness checker.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.