docs.roxen.comView this page in a printer friendly mode
DocsRoxenWebServer 5.1Web Developer ManualText Tags
Copyright  2013, Roxen Internet Software
Suggestions, comments & compliments
manuals@roxen.com
 DEMO  DOCS  PIKE
 COMMUNITY  DOWNLOAD
www.roxen.com



<ai>
<autoformat>
<basename>
<case>
<charset>
<comment>
<?comment ?>
<default>
<dirname>
<doc>
<foldlist>
<format-number>
<obox>
<random>
<recode>
<replace>
<sed>
<smallcaps>
<sort>
<strlen>
<substring>
<tablify>
<trimlines>
<wash-html>

<format-number></format-number>

Provided by module: Tags: Additional RXML tags

Formats a number according to pattern passed as an argument. Useful for adding grouping and rounding numbers to a fixed number of fraction digit characters.

<set variable='var.foo'>2318543.78</set> <p><format-number pattern='0.000'>&var.foo;</format-number></p> <p> <format-number pattern='#,###' group-separator=' ' decimal-separator=','> &var.foo; </format-number> </p>

2318543.780

2 318 544

It's important that the guidelines for the pattern are followed. Bad patterns will normally not cause an RXML-parse error, instead <format-number> will try to format the number according to the given pattern anyway.

<format-number> does not handle infinity.


Attributes

pattern="string"

The format pattern that dictates how the digits should be represented on screen.

The following symbols are allowed:

# - Digit

Placeholder for optional digits. The number of # after the decimal separator indicates number fo fraction digits to be shown.

<set variable='var.foo'>18543.78903</set> <p><format-number pattern='###'>&var.foo;</format-number></p> <p><format-number pattern='#.###'>&var.foo;</format-number></p>

18544

18543.789

0 - Zero Digit

Placeholder for required digits. If there are more digits required than given, the remaining positions will be filled with zeros.

0 should be placed to the right of # in the pattern in the integral part and to the left of # in the fraction part. If they are not and there are less digits than #, the zeros will be concatenated to the beginning of the integral part or the end of the fractional part giving unwanted results.

<set variable='var.foo'>543.78</set> <p><format-number pattern='#00.00'>&var.foo;</format-number></p> <p><format-number pattern='0000.000'>&var.foo;</format-number></p>

543.78

0543.780

. - Decimal separator

Placeholder for decimal separator. If more than one are present then the leftmost will be used. And the remaining will be printed out "as is".

The character used as decimal separator in the output can be changed with attribute "decimal-separator".

<set variable='var.foo'>543.789</set> <p><format-number pattern='##.##'>&var.foo;</format-number></p> <p> <format-number pattern='.######' decimal-separator=','> &var.foo; </format-number> </p>

543.79

543,789

, - Grouping separator

Placeholder for group separator. The character in output can be changed with attribute "group-separator".

<p><format-number pattern='#,###'>1677518543</format-number></p> <p><format-number pattern='#,###,###'>8543</format-number></p>

1,677,518,543

8,543

; - Pattern separator

Separates pattern for positive and negative result respectively. If more than one ; is present, everything after the second one will be ignored.

<p><format-number pattern='#,###.##;-#'>1000.50</format-number></p> <p><format-number pattern='#,###.##;-#'>-1000.50</format-number></p>

1,000.50

-1000

% - Percent

The number will be multiplied by 100 and a percent sign will be added to the output.

<p><format-number pattern='#,###%'>10.50</format-number></p> <p><format-number pattern='#.####%'>0.0003</format-number></p>

1,050%

0.03%

‰ - Per-mille

The number will be multiplied by 1000 and a per-mille sign will be added to the output.

<p><format-number pattern='##&#x2030;'>0.003</format-number></p>

3‰

- - minus sign

Default negative prefix

' - escape character

Can be used to escape characters that normally has another meaning.

<p><format-number pattern="#'.###">1255.34</format-number></p>

1.255


decimal-separator=""(.)

A character to be used as decimal separator. Can be useful for european formatting.

<p> <format-number pattern='###.##' decimal-separator=','> 543.78 </format-number> </p> <p>Even this attribute can be abused:</p> <p> <format-number pattern='###.##' decimal-separator=' &lt;--integral part, fractional part--&gt; '> 5023.643 </format-number> </p>

543,78

Even this attribute can be abused:

5023 <--integral part, fractional part--> 64


group-separator=""(,)

A character to be used as group separator. Can be useful for european formatting.

<set variable='var.foo'>20070901</set> <p> <format-number pattern='#,###' group-separator='.'> &var.foo; </format-number> </p> <p> <format-number pattern='####,##,##' group-separator='-'> &var.foo; </format-number> </p>

20.070.901

2007-09-01