XSLT format-number() Function

## XSLT Basic

XSLT HOME XSL Languages XSLT Introduction XSLT Browsers XSLT Transform XSLT <template> XSLT <value-of> XSLT <for-each> XSLT <sort> XSLT <if> XSLT <choose> XSLT Apply

## XSLT Advanced

XSLT on the Client XSLT on the Server XSLT Edit XML XSLT Editors XSLT Summary

## XSLT Examples

XSLT Examples

## XSLT References

XSLT Elements XSLT Functions

# XSLT format-number() Function

Complete XSLT Function Reference

## Definition and Usage

The format-number() function is used to convert a number into a string.

## Syntax

string format-number(number,format,[decimalformat])

## Parameters

Parameter | Description
--- | ---
number | Required. Specifies the number to be formatted

format

Required. Specifies the format pattern. Here are some of the characters used in the formatting pattern:

- 0 (Digit)
- # (Digit, zero shows as absent)
- . (The position of the decimal point Example: ###.##)
- , (The group separator for thousands. Example: ###,###.##)
- % (Displays the number as a percentage. Example: ##%)
- ; (Pattern separator. The first pattern will be used for positive numbers and the second for negative numbers)

decimalformat | Optional.

### Example 1

<?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>
<xsl:value-of select='format-number(500100, "#")' />
<br />
<xsl:value-of select='format-number(500100, "0")' />
<br />
<xsl:value-of select='format-number(500100, "#.00")' />
<br />
<xsl:value-of select='format-number(500100, "#.0")' />
<br />
<xsl:value-of select='format-number(500100, "###,###.00")' />
<br />
<xsl:value-of select='format-number(0.23456, "#%")' />
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View the XSL file and View the result.

Complete XSLT Function Reference

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE