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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
13.37Mb size Format: txt, pdf, ePub

Converting from dateTime

Destination Type
Rules
date
The date component of the
dateTime
value is returned, including the original timezone (or absence of a timezone).
dateTime
The value is returned unchanged.
gDay
Returns a
gDay
value containing the same day component and timezone (or absence of a timezone) as the original localized
dateTime
.
gMonth
Returns a
gMonth
value containing the same month component and timezone (or absence of a timezone) as the original localized
dateTime
.
gMonthDay
Returns a
gMonthDay
value containing the same month and day components and timezone (or absence of a timezone) as the original localized
dateTime
.
gYear
Returns a
gYear
value containing the same year component and timezone (or absence of a timezone) as the original localized
dateTime
.
gYearMonth
Returns a
gYearMonth
value containing the same year and month components and timezone (or absence of a timezone) as the original localized
dateTime
.
string
Returns the lexical representation of the
dateTime
, retaining the original timezone. The timezone is represented as
±hh:mm
, except for UTC, which is represented by the single letter
Z
. This is not the same as the canonical lexical representation defined in XML Schema, which always normalizes the timezone to UTC.
time
Returns the time component of the original localized
dateTime
, retaining its timezone.
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Converting from decimal

Destination Type
Rules
boolean
The value 0.0 is converted to
false
, and any other value is converted to
true
.
decimal
The value is returned unchanged.
double
The result is the closest
double
value to the supplied
decimal
. This may involve some loss of precision, because
decimal
values cannot usually be represented exactly in binary. The detailed rules are defined by saying that the result is equivalent to converting the
decimal
to a string and then converting the
string
to a
double
. If the value exceeds the largest possible
double
value this is treated as a numeric overflow, which gives three options: raising an error, returning Infinity, or returning the largest non-infinite double value.
float
As with conversion from
decimal
to
double
, the rules are defined by saying that the
decimal
is converted to a
string
, and the
string
is then converted to a
float
. The same considerations apply.
string
If the decimal represents a whole number (whether or not it is actually an instance of
xs:integer
), then it is represented on output as a string of decimal digits with no trailing zero and no decimal point. There is no truncation or rounding of significant digits, but insignificant leading or trailing zeroes are omitted. However, if the absolute value is less than one, a zero digit is included before the decimal point. The string starts with a
-
sign if the value is negative, but it never contains a
+
sign.
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Converting from double

Destination Type
Rules
boolean
The values positive zero, negative zero, and
NaN
are converted to
false
, and any other value is converted to
true
.
decimal
The result is the
decimal
value, within the range of
decimal
values that the implementation can handle, whose value is numerically closest to the value of the supplied
double
; if two values are equally close, the value is rounded toward zero. The range and precision of the
decimal
type is left to the implementor's discretion, so results may vary from one system to another. If the
double
is too large to be represented as a
decimal
, or if it is infinity or
NaN
, an error occurs.
double
The value is returned unchanged.
float
The special values
NaN
and infinity are converted to their
float
equivalents. Otherwise, binary digits are removed from the least significant end of the value to make the value fit within the precision supported by the
float
type. If the exponent is larger than the largest exponent allowed by a
float
, the result is positive or negative infinity. If the exponent is smaller than the smallest exponent allowed by a
float
, the result is positive or negative zero.
string
If the value is
NaN
(not-a-number), it is output as the string
NaN
. Positive and negative infinity are represented as
INF
and
-INF
. Numbers whose absolute value is greater than or equal to 1.0e–6, and less than 1.0e+6, are represented in conventional decimal notation; for example,
17.523
or
42
(never
42.0
). Numbers outside this range are output in “scientific” notation, in a form such as
1.56003E-5
. There are constraints on the precise form of this value; for example, it includes no plus sign and no insignificant leading or trailing zeros except adjacent to the decimal point, and the

Other books

The Information by James Gleick
Haunted Creek by Ann Cliff
The Assassin's List by Scott Matthews