Breaking News


The <xsl:number> element performs two functions:

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″/> 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 ( (
The xsl:number element has two possible uses. It can determine the sequence number for the current node and it can format a number for display in the output.

The sequence number is the integer position of the current node in a source document (source tree). There are actually three ways that the sequence number can be determined and you can use the level attribute to choose which way.

The formatting process converts either the sequence number or the number provided by the value attribute to a string. By using various attributes of the xsl:number element, you can exert great control over the appearance of the formatted number in the output.
In comparison, the xsl:decimal-format element defines the symbols and characters used by the format-number function to convert numbers to strings. This is a self-closing element and it cannot contain any child elements or any content.
The optional count attribute dictates what nodes are to be counted. Only nodes that match the pattern are counted. The default is to count any node that matches the pattern of the current node.
format=”{ string }”
The optional from attribute specifies a starting point from which the sequential counting will start. The nodes are matched to the pattern to find the starting point.
The <xsl:sort> element sorts a set of nodes according to the criteria specified:
<xsl:apply-templates select=”row”>
<xsl:sort data-type=”number” select=”entry[2]”/>
It can appear as a child of <xsl:apply-templates> or <xsl:for-each>. It can also be nested. The xsl:sortelement is used to define a sort key. This sort key determines the order in which selected nodes are processed by the xsl:for-each or xsl:apply-templates elements.
A sort can be based upon more than one xsl:sort element. Each sort is applied in the order in which it occurs. Duplicate values are left in document order. After the first sort has reordered the nodes, the second sort is applied to any nodes that had duplicate values in the first sort. The third sort is applied to any nodes that had duplicate values in the second sort, and so on.
This is not a self-closing element. The separate closing element is mandatory.
case-order=”upper-first” | “lower-first”
The optional case-order attribute dictates whether the sort will have upper or lower case letters listed first in the sort. The default is to list upper case first.
data-type=”number” | “qname” | “text”
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- DWXMLSource="sample1.xml" -->
<!DOCTYPE xsl:stylesheet  [

	<!ENTITY nbsp   " ">

	<!ENTITY copy   "©">

	<!ENTITY reg    "®">

	<!ENTITY trade  "™">

	<!ENTITY mdash  "—">

	<!ENTITY ldquo  "“">

	<!ENTITY rdquo  "”"> 

	<!ENTITY pound  "£">

	<!ENTITY yen    "¥">

	<!ENTITY euro   "€">


<xsl:stylesheet version="1.0" xmlns:xsl=

<xsl:output method="html" encoding="iso-8859-1" 
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"

<xsl:template match="/">



<meta http-equiv="Content-Type" 
content="text/html; charset=iso-8859-1"/>

<title>XSL Sorting Example</title>



<xsl:for-each select="ebiz/employee_details">

<xsl:sort select="age" order="descending"/>

<div style="background-color:#009999; border:thin 
#000099 solid; width:80%">

	<xsl:value-of select="emp_id"></xsl:value-of><br />

	<xsl:value-of select="lname"></xsl:value-of> 

	<span style="color:#000099"><xsl:value-of select="fname"
></xsl:value-of></span><br />

	<xsl:value-of select="department"></xsl:value-of><br />

	<xsl:value-of select="designation"></xsl:value-of>