only for RuBoard |
xsl:number inserts a formatted number into the result tree.
Attribute Name | Enforced | Description | Values |
---|---|---|---|
level | Optional | Specifies what level of the source tree should be considered . The default is single . | single , multiple , or any |
count | Optional | A pattern that specifies what nodes should be counted at those levels. If count attribute is not specified, 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. | A pattern |
from | Optional | Specifies where counting starts. | A pattern |
value | Optional | Allows specifying the numeric value rather than maintaining a running list. If no value attribute is specified, xsl:number inserts one based on the current node in the source tree. | A number-expression, such as count() or position() . |
format | Optional | Specifies the format that can be used. | A string. A formats as a capital letter. 1 formats as a decimal. I formats as a capital roman numeral, and i formats as a lower-case roman numeral. |
lang | Optional | Specifies the language's alphabet to use. If no language is specified, the language is determined from the system's environment. | NMToken |
letter-value | Optional | Specifies how sorting should occur for characters . For example, an alphabetic sort of the sequence ( 1,2,11,12 ) might yield ( 1,11,12,2 ) while traditional would yield ( 1,2,11,12 ). | alphabetic or traditional . The default is traditional . |
grouping-separator | Optional | Specifies the grouping separator in decimal numbering sequences. An example is a thousands separator. | A character. If grouping- size is x , attribute is ignored. |
grouping-size | Optional | Specifies the size of the decimal to group on. Separating thousands would mean a grouping-size of three. | A number. If grouping - separator is not specified, this attribute is ignored. |
Suppose that you want to create a numbered outline from the data in an XML file. Consider the following XML file, links.xml :
<?xml version="1.0" encoding="utf-8" ?> <links> <link URL="http://www.newriders.com"> <section name="New Books"> <feature>XML and ASP.NET</feature> <feature>Inside XML</feature> <feature>Inside XSLT</feature> </section> <section name="Contact Us"> <feature>Contact by email</feature> <feature>Contact by Phone</feature> </section> </link> <link URL="http://msdn.microsoft.com"> <section name="MSDN Library" /> <section name="Downloads" /> </link> <link URL="http://www.xmlandasp.net"> <section name="Articles"> <feature>Obtaining ObjectContext</feature> <feature>Calling Java from ASP</feature> <feature>Introduction to XSLT</feature> </section> </link> </links>
Using the xsl:number element, you can use the level attribute with a value of multiple to generate the outline. The URL is displayed with a roman numeral, the section is displayed with a capital letter, and the feature is displayed with a decimal. This stylesheet is called outline.xslt .
<?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="link"> <xsl:number level="multiple" format="I. " /> <xsl:value-of select="@URL" /> <xsl:apply-templates /> </xsl:template> <xsl:template match="section"> <xsl:number level="multiple" format="A. " /> <xsl:value-of select="@name" /> <xsl:apply-templates /> </xsl:template> <xsl:template match="feature"> <xsl:number level="multiple" format="1. " /> <xsl:value-of select="." /> </xsl:template> </xsl:stylesheet>
Applying the stylesheet outline.xslt to the XML document links.xml produces the following output. This result is not XML, and you have omitted the XML decaration. The document is formatted with carriage returns for clarity:
I. http://www.newriders.com A. New Books 1. XML and ASP.NET 2. Inside XML 3. Inside XSLT B. Contact Us 1. Contact by email 2. Contact by Phone II. http://msdn.microsoft.com A. MSDN Library B. Downloads III. http://www.xmlandasp.net A. Articles 1. Obtaining ObjectContext 2. Calling Java from ASP 3. Introduction to XSLT
xsl:copy, xsl:element, xsl:for-each, xsl:if, xsl:otherwise, xsl:param, xsl:template, xsl:variable, xsl:when, xsl:with-param, output elements
None.
only for RuBoard |