?
本文檔使用
php中文網(wǎng)手冊(cè) 發(fā)布
<xsl:number> 元素用于測(cè)定在源中當(dāng)前節(jié)點(diǎn)的整數(shù)位置。它也用于對(duì)數(shù)字進(jìn)行格式化。
<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"/>
屬性 | 值 | 描述 |
---|---|---|
count | expression | 可選。一個(gè) XPath 表達(dá)式,規(guī)定要計(jì)數(shù)的節(jié)點(diǎn)。 |
level | single multiple any | 可選??刂迫绾畏峙湫蛱?hào)。 可以使用的值:
|
from | expression | 可選。一個(gè) XPath 表達(dá)式,規(guī)定從何處開(kāi)始計(jì)數(shù)。 |
value | expression | 可選。規(guī)定用戶提供的數(shù)字,用于代替產(chǎn)生的序號(hào)。 |
format | formatstring | 可選。定義數(shù)字的輸出格式??梢允褂玫闹担?ul class="list-group list-paddingleft-2"> format="1" 結(jié)果 1 2 3 . . format="01" 結(jié)果 01 02 03 (Netscape 6 不支持) format="a" 結(jié)果 a b c . . (Netscape 6 不支持) format="A" 結(jié)果 A B C. . (Netscape 6 不支持) format="i" 結(jié)果 i ii iii iv . . (Netscape 6 不支持) format="I" 結(jié)果 I II III IV . . (Netscape 6 不支持) |
lang | languagecode | 可選。規(guī)定用于編號(hào)的語(yǔ)言字母表。(Netscape 6 不支持) |
letter-value | alphabetic traditional | 可選。規(guī)定選定語(yǔ)言的編號(hào)是字母序列("alphabetic")還是其他序列("traditional")。值 "alphabetic" 指定字母序列;值 "traditional" 指定其他序列。默認(rèn)是 "alphabetic"。 |
grouping-separator | character | 可選。規(guī)定使用什么字符來(lái)分隔組或數(shù)字。默認(rèn)是逗號(hào)。 |
grouping-size | number | 可選。規(guī)定由 grouping-separator 屬性指定的分隔字符分隔的每個(gè)分組中的數(shù)字個(gè)數(shù)。默認(rèn)是 3。 |
<xsl:number value="250000" grouping-separator="."/> Output: 250.000
<xsl:number value="250000" grouping-size="2"/> Output: 25,00,00
<xsl:number value="12" grouping-size="1" grouping-separator="#" format="I"/> Output: X#I#I
<?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>