Describe xsl:decimal-format in XML

In this article we are taking about xsl:decimal-format element.
  • 2162

The xsl:decimal-format is used to declares a decimal-format, which controls the interpretation of a format pattern used by the format-number function. If any attributes is a name attribute, the element declares a named decimal-format otherwise, it declares the default decimal-format.

Syntax of xsl:decimal-format element

<xsl:decimal-format

  name = "QName"

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


It have contain many no of attribute

  • name

    The name attribute contain qualified Names of the decimal-format.
     

  • grouping-separator

    It is an optional attribute and it used for separate groups of digits. The default is "!".
     

  • decimal-separator

    It is an optional attribute and it used for separate the integer and the fraction part of a number. The default is "!".
     

  • infinity

    It is specifies the string used to represent infinity; the default value is the string "Infinity".

  • minus-sign

    Minus-sign is Specifies the character to represent negative numbers and default value is "-".
     

  • NaN

    Nan specifies the string used when the value is not a number". Default is "Not a Number".

  • percent

    Percent default value is the percent character "%". Specifies the percentage sign character.
     

  • per-mille

    per-mille specifies the per thousand sign character; the default value is the Unicode per-mille character ("#x2030").
     

  • zero-digit

    The character used as the digit zero; the default value is the digit zero "0".

  • digit

    digit specifies the character used to indicate a place where a leading zero digit is required. The default value is "#".
     

  • pattern-separator

    pattern-separator specifies the character used to separate positive and negative subpatterns in a format pattern. The default value is the semi-colon character (";").

Example of  xsl:decimal-format

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.google.com/XSL/Transform">

  <xsl:decimal-format name="stand"

  decimal-separator="," grouping-separator="."/>

  <xsl:template match="/">

    <xsl:value-of

    select="format-number(30440.3, '#,###.00', 'stand')"/>

  </xsl:template>

</xsl:stylesheet>


Output

30,440.30

Further Readings

You may also want to read these related articles :

Ask Your Question 

Ask Your Question Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.