decimal-format

decimal-format is a root level statement that defines the characters and symbols that are to be used in converting numbers into strings. The various names within the block are identical to the XSLT attributes.

Syntax
<decimal-format> ::= "decimal-format" <qname> "{" ( ( "decimalSeparator" <quote> <alpha character> <quote> )? | ( "groupingSeparator" <quote> <alpha character> <quote> )? | ( "infinity" <quote> <alphanumeric string> <quote> )? | ( "minusSign" <quote> <alphanumeric character> <quote> )? | ( "notNumber" <quote> <alphanumeric string> <quote> )? | ( "percent" <quote> <alphanumeric character> <quote> )? | ( "perMille" <quote> <alphanumeric character> <quote> )? | ( "zeroDigit" <quote> <alphanumeric character> <quote> )? | ( "digit" <quote> <alphanumeric character> <quote> )? | ( "patternSeparator" <quote> <alphanumeric character> <quote> )? )+ "}"
Options
name a name defining the name of the funprocction to call.
Elements

The range of values within an output block is identical to the XSLT definition. At least one is required.

decimal-separator Specifies the thousands separator character. The default is ",".
grouping-separator Specifies the thousands separator character. The default is ",".
infinity Specifies the string used to represent infinity. The default is the string "Infinity".
NaN Specifies the string used when the value is not a number. The default is the string "NaN".
percent Specifies the percentage character. The default is "%".
perMille Specifies the per thousand character. The default is "‰".
zeroDigit Specifies the digit zero character. The default is "0".
digit Specifies the character used in the format pattern to stand for a digit. The default is "#".
patternSeparator Specifies the character separating positive and negative subpatterns in a format pattern. The default is the semi-colon ";".
Examples

A simple example to define the format of numbers: the thousands separator and decimal separator.

stylesheet { version "1.0" decimal-format decName { decimal-separator "," grouping-separator "." } }

compiles to

<?xml version="1.0" encoding="UTF-8"?> <stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0"> <decimal-format name="decName" decimal-separator="," grouping-separator="."/> </stylesheet>
Errors

Forgetting the name:

stylesheet { version "1.0" decimal-format { decimal-separator "." grouping-separator "." } }

will give

**** (115) Expected name after "decimal-format" in line 4 Insert name.

Having an empty expression:

stylesheet { version "1.0" decimal-format decName { decimal-separator "." grouping-separator "" } }

will give

**** (140) Null string instead of "single character" in "grouping-separator" in line 6 Check string expression.

Leaving out the expected expression completely:

stylesheet { version "1.0" decimal-format { decimal-separator grouping-separator "," } }

will give

**** (139) Found unexpected reserved word "grouping-separator" in "decimal-separator" in line 6 Check spelling.
Copyright 2024 Hugh Field-Richards. All Rights Reserved.