Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

XSLT <xsl:decimal-format> elements


May 28, 2021 XSL T


Table of contents


XSLT and lt;xsl: decimal-format-gt; elements

This section is an introduction to the use of the elements of XSLT and lt;xsl:decimal-format.


XSLT <xsl:decimal-format> elements Complete XSLT element reference manual

Definitions and usages

The element defines the characters and symbols to use when converting numbers into strings through the format-number() function.

Not all countries use the same characters to separate the small and integer parts, or to group the numbers. You can change specific characters to other symbols by using the element of the .lt;xsl:decimal-format.

The element is the top level element.

The format-number() function can refer to the element by name.


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"/>

Property

Attributes value describe
name name Optional.The name is specified for this format.
decimal-separator char Optional.Specifies the decimal point character.The default is ".".
grouping-separator char Optional.Provisions the thousands of separators.The default is ",".
infinity string Optional.It is specified to express an infinite string.The default is "infinity".
minus-sign char Optional.The characters indicating the negative number are specified.The default is "-".
NaN string Optional.The string used when the value is not used.The default is "nan".
percent char Optional.The character of the percent symbol is specified.The default is "%".
per-mille char Optional.Specify the character of the thousandth.The default is "‰".
zero-digit char Optional.Specify the characters of numbers 0.The default is "0".
digit char Optional.The character is specified, which is used to indicate where you need to use numbers.The default is #.
pattern-separator char Optional.The character is specified, which is used to separate the positive submersible submersible in the format mode.The default is ";".

Instance 1

The following example shows how to format it as a European currency (note that the third argument in the format-number() function refers to the name of the element.

<?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 <xsl:decimal-format> elements Complete XSLT element reference manual