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

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

Converting from gYearMonth

Destination Type
Rules
gYearMonth
The value is returned unchanged.
string
The output will be in the form
YYYY-MM
, followed by a timezone if the value includes one, formatted as for
xs:date
. Negative years are preceded by
-
.
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Converting from hexBinary

Destination Type
Rules
base64Binary
A
base64Binary
value is constructed containing the same octets (bytes) as the original
hexBinary
value.
hexBinary
The value is returned unchanged.
string
The canonical lexical representation of the
hexBinary
value is returned, as a string. This representation uses two hexadecimal digits to represent each octet in the value. The digits used are 0–9 and A–F (uppercase).
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Converting from NOTATION

Destination Type
Rules
NOTATION
Casting to
xs:NOTATION
itself is not permitted, because
xs:NOTATION
is an abstract type. When casting to a type derived from
xs:NOTATION
, the value is returned unchanged, provided that it meets the rules for the subtype.
string
If the value contains a prefix, the result is in the form
prefix:localName
; otherwise, the result is the local name.
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Converting from QName

Destination Type
Rules
QName
The value is returned unchanged.
string
If the value contains a prefix, the result is in the form
prefix:localName
; otherwise, the result is the local name.
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Converting from string

Destination Type
Rules
anyURI
base64Binary
boolean
date
dateTime
decimal
double
duration
float
gDay
gMonth
gMonthDay
gYear
gYearMonth
hexBinary
string
time
The string is converted to the destination type using the same rules as are applied during schema validation of an element or attribute declared with this type.
Firstly, whitespace is normalized or collapsed as determined by the
whiteSpace
facet of the target type. (Except for the trivial conversion from string to string, this means that leading and trailing whitespace is removed). Then the resulting value is tested to check that it is a valid lexical representation for the specified atomic type, and the corresponding value of that type is returned.
The rules are refined in the case of the date and time types to allow the timezone information to be retained (in XML Schema, these are lost during the process of validation).
NOTATION
Conversion to
xs:NOTATION
itself is not allowed, because
xs:NOTATION
is an abstract type. Conversion to a type derived from
xs:NOTATION
follows the same rules as conversion to a QName—the value must be supplied as a string literal.
QName
Casting from a string to a QName is allowed only if the value is supplied as a string literal. The namespace context is taken from the static context of the XPath expression. If the
QName
contains no prefix, then the default namespace for elements and types is used (in XSLT, this is the namespace declared using the
xpath-default-namespace
attribute).
untypedAtomic
The returned value contains the same characters as the original string, but the result is labeled as
untypedAtomic
.

Converting from time

Destination Type
Rules
string
Returns the canonical lexical representation of the time, retaining the original timezone. For example, the value might be output as
13:20:05.012+01:00
. The timezone is represented as
±hh:mm
, except for UTC, which is represented by the single letter
Z
.
time
The value is returned unchanged.
untypedAtomic
Returns the same result as converting to a string, but the result is labeled as
untypedAtomic
.

Other books

Other Women by Lisa Alther
Marley's Menage by Jan Springer
Koshi by Annie Nicholas
Aurora Dawn by Herman Wouk
The Tower: A Novel by Uwe Tellkamp