XSLT Function FormatNumber

Formats number according to the specified format.

NAMESPACE

xmlns:AS="http://schema.advantages.cz/AsapFunctions"

SYNTAX

string FormatNumber(decimal number, string format)

PARAMETERS

Name Description
number Number to be formatted.
format Requested format. For info about possible formats see Standard numeric format strings | Microsoft Docs.

EXAMPLE

This example rounds a number using a provided profile.
Source XML

<ROOT> 
    <test number="3.1415927"> 
</ROOT>

Stylesheet

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:AS="http://schema.advantages.cz/AsapFunctions" 
    xmlns:date="http://exslt.org/dates-and-times" 
    exclude-result-prefixes="AS date"> 
    <xsl:template match="/"> 
        <test test="AS:FormatNumber(/ROOT/test/@number, 'F2')"/> 
    </xsl:template> 
</xsl:stylesheet>