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
6.45Mb size Format: txt, pdf, ePub

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)
.

Other books

Fire Me Up by Kimberly Kincaid
Attica by Kilworth, Garry
Virtue of a Governess by Anne Brear
No Beast So Fierce by Edward Bunker
B00BNB54RE EBOK by Jaudon, Shareef
Touch the Horizon by Iris Johansen