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:

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> 

Converting Static HTML to XML

This video tutorial covers how to convert static HTML to XML.

Java Code Generation

The Stylus Studio Java Codce Generator lets you generate deployable Java code for XQuery and XSLT at the push of a button!

DTD vs. Schema

Stylus Studio provides tools for working with both W3C XML Schema and DTD's - this tutorial explains what the differences are between the two, providing a technical comparison of DTD vs Schema.

XML-DEV Discussion Forum

XML-DEV is a leading technical forum for XML discussion and a valuable free XML learning resource. Subscribe to the XML-DEV email discussion forum today to help further your XML education.

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.