Latest web development tutorials

XSLT <xsl: decimal-format> element

XSLT Elements Reference Manual Complete XSLT Element Reference Manual

Definition and Usage

<Xsl: decimal-format> element defines the characters and symbols when by format-number () function to convert a number to a string to be used.

Not all countries use the same character to separate the integer part and the fractional part, or digits are grouped. By <xsl: decimal-format> element, you can change the character of the specific other symbols.

This element is the top element (top level element).

format-number () function can be referred to by name (name) <xsl: decimal-format> element.


grammar

<xsl:decimal-format
name="name"
decimal-separator="char"
grouping-separator="char"
infinity="string"
minus-sign="char"
NaN="string"
percent="char"
per-mille="char"
zero-digit="char"
digit="char"
pattern-separator="char"/>

Attributes

属性 描述
name name 可选。为此格式规定名称。
decimal-separator char 可选。规定小数点字符。默认是 "."。
grouping-separator char 可选。规定千的分隔字符。默认是 ","。
infinity string 可选。规定用来表示无穷大的字符串。默认是 "Infinity"。
minus-sign char 可选。规定表示负数的字符。默认是 "-"。
NaN string 可选。规定当值不是数字时使用的字符串。默认是 "NaN"。
percent char 可选。规定百分比符号的字符。默认是 "%"。
per-mille char 可选。规定千分号的字符。默认是 "‰"。
zero-digit char 可选。规定数字 0 的字符。默认是 "0"。
digit char 可选。规定字符,该字符用于指示需要使用数字的地方。默认是 #。
pattern-separator char 可选。规定字符,该字符用于分隔格式模式中的正负子模式。默认是 ";"。

Example 1

The following example shows how to format the European currency (Please note, format-number () function of the third parameter references <xsl: decimal-format> element's name):

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:decimal-format name="euro"
decimal-separator="," grouping-separator="."/>

<xsl:template match="/">
<xsl:value-of
select="format-number(26825.8, '#.###,00', 'euro')"/>
</xsl:template>

</xsl:stylesheet>

Output:

26,825.80


XSLT Elements Reference Manual Complete XSLT Element Reference Manual