XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (154 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
7.9Mb size Format: txt, pdf, ePub
zero-digit
optional
Character
Character used in a format pattern to indicate a place where a leading or trailing zero digit is required, even if it is not significant. Default value is
0
(x30). This character must be one that is classified in the Unicode database as a digit character, with the numeric value zero.
digit
optional
Character
Character used in a format pattern to indicate a place where a digit will appear, provided it is a significant digit. Default value is
#
(x23).
pattern-separator
optional
Character
Character used in a format pattern to separate the subpattern for positive numbers from the subpattern for negative numbers. Default value is
;
(x3B).

Content

None; the element is always empty.

Effect

If a
name
attribute is supplied, the

element defines a named decimal format; otherwise, it defines attributes of the default decimal format. A named decimal format is used by the
format-number()
function when it is called with three arguments (the third argument is the name of a decimal format); the default decimal format is used when the
format-number()
function is called without a third argument.

It is possible to have more than one

element for the default decimal format, or more than one for a decimal format with a given name. The effective value of a given attribute (such as
zero-digit
) is taken from the declaration with the highest import precedence that specifies a value for the required attribute. It is an error if this selects more than one declaration, unless the values specified are the same.

The

element does not directly define the display format of a number. Rather it defines the characters and strings used to represent different logical symbols. Some of these logical symbols occur in the
picture string
used as an argument to the
format-number()
function, some of them occur in the final output number itself, and some are used in both. The actual display format of a number depends both on the picture string and on the choice of decimal format symbols.

For example, if there is an

element as follows:

                    decimal-separator=“,”

                    grouping-separator=“.” />

then the function call:

format-number(1234.5, ‘#.##0,00’, ‘european’)

will produce the output:

1.234,50

The use of the
.
and
,
characters in both the picture string and the output display is determined by the named

element, but the number of digits displayed, and the use of leading and trailing zeros, is determined solely by the picture string.

The structure of a picture string is defined in the description of the
format-number()
function in Chapter 13, page 788. The syntax of the picture string uses a number of special symbols: the actual characters used for these symbols are defined in the relevant

element. These symbols are:

decimal-separator

grouping-separator

percent

per-mille

zero-digit

digit

pattern-separator

The

element also defines characters and strings that are used, when required, in the actual output value. Some of these are the same as characters used in the picture string, others are different. These characters and strings are:

decimal-separator

grouping-separator

infinity

minus-sign

NaN

percent

per-mille

zero-digit

For example, if the

element defines the infinity string as
***
, then the output of
format-number(1e0 div 0, $format)
will be
***
, regardless of the picture string.

Other books

Malice by John Gwynne
Mullumbimby by Melissa Lucashenko
Chris Collett - [Tom Mariner 01] by The Worm in The Bud (txt)
The Tartan Touch by Isobel Chace
hislewdkobo by Adriana Rossi
The Penny by Joyce Meyer, Deborah Bedford
All Bets Are Off by Lacey Layton
Last Shot by John Feinstein
Embrace the Night by Roane, Caris