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

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

If an element or attribute is list-valued, then the type annotation on the node may be a list type, for example,
attribute(*,
xs:IDREFS)
. But when you extract the typed value of this node using the
data()
function, the result is a sequence of
xs:IDREF
values, which you can test using the sequence type descriptor
xs:IDREF*
. You cannot write
data(@x) instance of xs:IDREFS
, because
xs:IDREFS
is not an atomic type.

Similarly, when the schema defines an element or attribute as having a union type, then the type annotation on the node will be the union type, but the atomic values that result from atomization will belong to one or another of the members of the union type.

The
instance of
expression tests the dynamic type of a value, that is, the actual type of the value after the operand expression has been evaluated. This may or may not be the same as the static type of the operand expression. The static type of an expression will always be a supertype of the dynamic type of any possible value of the expression (or the same type, of course).

Here are some examples of
instance of
expressions used in context:

Expression
Effect
$seq[. instance of node()]
Selects the items in
$seq
that are nodes, discarding any that are atomic values.
if (some $s in $seq
satisfies $s
instance of node())
then ...
Tests whether the sequence
$seq
contains at least one node.
if (not($seq instance of
xs:anyAtomicType*))
then ...
This has exactly the same effect as the previous example. If a sequence is not an instance of
xs:anyAtomicType*
, then it must contain at least one node.
$p instance of item() +
This tests whether
$p
is a non-empty sequence. The result is the same as calling
exists($p)
.
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
13.34Mb size Format: txt, pdf, ePub
ads

Other books

The Black Witch of Mexico by Colin Falconer
A Question of Magic by E. D. Baker
Wet Part 3 by Rivera, S Jackson
Cómo nos venden la moto by Ignacio Ramonet Noam Chomsky
Miracle Pie by Edie Ramer
Confidentially Yours by Charles Williams
The Thirteen Hallows by Michael Scott, Colette Freedman
Fatal February by Barbara Levenson
Bound For Eden by Tess Lesue