XSLT <xsl:십진수 형식>
❮ 완전한 XSLT 요소 참조
정의 및 사용
<xsl:decimal-format> 요소는 format-number() 함수를 사용하여 숫자를 문자열로 변환할 때 사용할 문자와 기호를 정의합니다.
모든 국가에서는 정수 부분에서 소수 부분을 구분하고 숫자를 그룹화하는 데 동일한 문자를 사용하지 않습니다. <xsl:decimal-format> 요소를 사용하여 특수 문자를 다른 기호로 변경할 수 있습니다.
이 요소는 최상위 요소입니다.
format-number() 함수는 이름으로 <xsl:decimal-format> 요소를 참조할 수 있습니다.
통사론
<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"/>
속성
Attribute | Value | Description |
---|---|---|
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" |
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" |
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" |
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 ";" |
실시예 1
아래 예는 유럽 통화로 형식을 지정하는 방법을 보여줍니다(format-number()의 세 번째 인수는 <xsl:decimal-format> 요소의 이름을 나타냅니다.
<?xml version="1.0" encoding="UTF-8"?>
<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 요소 참조