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

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

Both the
cast
as
and
castable
as
operators perform atomization on the supplied value. This means that if the supplied value is a node, its typed value is first extracted. If the operand (after atomization) is a sequence of more than one item, then a type error occurs in the case of
cast
as
, or the value
false
is returned in the case of
castable
as
.

There is a shorthand for a
cast
as
expression, which is to use a constructor function. For example, the expression
@A
cast
as
xs:integer?
can be rewritten as a function call,
xs:integer(@A)
. There is a constructor function available for every built-in atomic type, and for every named atomic type in an imported schema, and its effect is identical to using the
cast
as
expression with the
?
option (that is, if an empty sequence is supplied to a constructor function, it returns an empty sequence). The only cases where you need to use the full
cast
as
expression are:

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

Other books

The Legend That Was Earth by James P. Hogan
The Hired Hero by Pickens, Andrea
Everyone is Watching by Megan Bradbury
The Three Wise Guides by Terri Reid
Salvation by Noelle Adams
Sweet Talk Boxed Set (Ten NEW Contemporary Romances by Bestselling Authors to Benefit Diabetes Research plus BONUS Novel) by Novak, Brenda, Anne, Melody, Duke, Violet, Foster, Melissa, Maxwell, Gina L, Miller, Linda Lael, Woods, Sherryl, Holmes, Steena, James, Rosalind, O'Keefe, Molly, Naigle, Nancy
Gotcha! by Christie Craig