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

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:decimal-format> 元素


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

Definition and Usage
定义和用法

The <xsl:decimal-format> element defines the characters and symbols to be used when converting numbers into strings, with the format-number() function.
<xsl:decimal-format>元素的作用是:定义了将数字转换为字符时所要用到的字符和符号(使用format-number()函数)。

All countries do not use the same characters for separating the decimal part from the integer part, and for grouping digits. With the <xsl:decimal-format> element you can change special characters to other symbols.
所有的国家都使用相同的字符来分隔小数部分和整数部分,或对数位进行分组。通过<xsl:decimal-format>元素,你可以将指定的字符改变为其他符号。

This element is a top level element.
这个元素是一个顶级元素。

The format-number() function can refer to the <xsl:decimal-format> element by name.
format-number()函数可以通过名称查阅<xsl:decimal-format>元素。


Syntax
语法

<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 Optional. Specifies a name for this format
可选参数。指定格式名称
decimal-separator char Optional. Specifies the decimal point character. Default is "."
可选参数。指定小数点字符,默认为“.”
grouping-separator char Optional. Specifies the thousands separator character. Default is ","
可选参数。指定千位分隔字符,默认为“,”
infinity string Optional. Specifies the string used to represent infinity. Default is "Infinity"
可选参数。指定代表“无限大”的字符,默认为“Infinty”
minus-sign char Optional. Specifies the character to represent negative numbers. Default is "-"
可选参数。指定了负数字符,默认为“-”
NaN string Optional. Specifies the string used when the value is not a number". Default is "NaN"
可选参数。指定了非数字字符,默认为“NaN”
percent char Optional. Specifies the percentage sign character. Default is "%"
可选参数。指定了百分号字符,默认为“%”
per-mille char Optional. Specifies the per thousand sign character. Default is "‰"
可选参数。指定了千分号字符。默认为“‰”
zero-digit char Optional. Specifies the digit zero character. Default is "0"
可选参数。指定了0位字符,默认为0
digit char Optional. Specifies the character used to indicate a place where a digit is required. Default is #
可选参数。指定了数位字符,默认值为“#”
pattern-separator char Optional. Specifies the character used to separate positive and negative subpatterns in a format pattern. Default is ";"
可选参数。指定了格式样式中用于分隔正、负二级样式的字符

Example 1
案例1

The example below shows how to format to European currency (note that the third argument in format-number() refers to the name of the <xsl:decimal-format> element:
下面的案例展示了如何格式化为欧洲货币(注意:format-number() 函数中的第三个自变量查阅了<xsl:decimal-format>元素的名称):

<?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>

输出结果:

26.825,80

评论 (0) All

登陆 | 还没注册?