当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT <xsl:number> 元素

XSL/XSLT
XSL 语言
XSLT 介绍
XSLT 浏览器
XSLT 转换
<xsl:template>
<xsl:value-of>
<xsl:for-each>
<xsl:sort>
<xsl:if>
<xsl:choose>
<xsl:apply-templates>
XSLT - 客户端
XSLT - 服务器端
XSLT - 编辑XML
XSLT 摘要
XSLT 元素参考
XSLT 函数
XSL 编辑器

XSL/XSLT 中的 XSLT <xsl:number> 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 210 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The <xsl:number> element is used to determine the integer position of the current node in the source. It is also used to format a number.
<xsl:number> 元素的作用是:确定数据源中当前节点的整数位置。它也被用来格式化一个数字。


Syntax
语法

<xsl:number
count="expression"
level="single|multiple|any"
from="expression"
value="expression"
format="formatstring"
lang="languagecode"
letter-value="alphabetic|traditional"
grouping-separator="character"
grouping-size="number"/>

Attributes
属性

属性 描述
count expression Optional. An XPath expression that specifies what nodes are to be counted
可选参数。指定一个XPath表达式,该表达式是用来指明被计算的结节点对象的
level single
multiple
any
Optional. Controls how the sequence number is assigned
可选参数。控制分派序列数的方式

Can be one of the following:
可以是以下值:

  • single (default)
    单值(默认值)
  • multiple
    多值
  • any (not supported by Netscape 6)
    任意值(Netscape6不支持)
from expression Optional. An XPath expression that specifies where the counting will start
可选参数。指定一个XPath表达式,它是用来指定开始计数的起点
value expression Optional. Specifies a user-provided number that is used in place of a sequence generated number
可选参数。指定一个用户提供数,该数字是用来代替序列数(按照顺序产生的)的
format formatstring

Optional. Defines the output format for the number. Can be one of the following:

可选参数。为数字定义输出格式。可以是下值中的一个:

  • format="1" results in 1 2 3 . .
    format="1" ,输出结果是1 2 3..
  • format="01" results in 01 02 03 (not supported by Netscape 6)
    format="01" ,输出结果是01 02 03 (Netscape 6不支持)
  • format="a" results in a b c . . (not supported by Netscape 6)
    format="a" ,输出结果是a b c (Netscape 6不支持)
  • format="A" results in A B C. . (not supported by Netscape 6)
    format="A" ,输出结果是A B C(Netscape 6不支持)
  • format="i" results in i ii iii iv . . (not supported by Netscape 6)
    format="i" ,输出结果是i ii iii iv (Netscape 6不支持)
  • format="I" results in I II III IV . . (not supported by Netscape 6)
    format="I" ,输出结果是I II III IV(Netscape 6不支持)
lang languagecode Optional. Specifies the language alphabet to be used for the numbering (Not supported by Netscape 6)
可选参数。指定用于编号的字母(Netscape 6不支持)
letter-value alphabetic
traditional
Optional. Specifies whether the numbering in the selected language is alphabetic or traditional. The default is alphabetic
可选参数。指定选定的编号方式是字母方式还是使用传统方式。默认值是字母方式
grouping-separator character Optional. Specifies what character should be used to separate groups of digits. The default is the comma
可选参数。指定数位分割字符。默认是逗点(,)
grouping-size number Optional. Specifies how many digits are in the groups that are being separated by the character specified in the grouping-separator attribute. The default is 3
可选参数。指定以多少个数字为一组对整段数字进行分组。默认是以3个数字为一组

Example 1
案例1

<xsl:number value="250000" grouping-separator="."/>

输出结果:

250.000

Example 2
案例2

<xsl:number value="250000" grouping-size="2"/>

输出结果:

25,00,00

Example 3
案例3

<xsl:number value="12" grouping-size="1"
grouping-separator="#" format="I"/>

输出结果:

X#I#I

Example 4
案例4

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/"> <html> <body> <p> <xsl:for-each select="catalog/cd"> <xsl:number value="position()" format="1" /> <xsl:value-of select="title" /><br /> </xsl:for-each> </p> </body> </html>
</xsl:template>
</xsl:stylesheet>

评论 (0) All

登陆 | 还没注册?