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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
8.69Mb size Format: txt, pdf, ePub
Occurrence Indicator
Meaning
*
Zero or more occurrences allowed
+
One or more occurrences allowed
?
Zero or one occurrence allowed

If no
OccurrenceIndicator
is present, then a sequence will only conform to the type if it contains exactly one item.

The rest of the syntax provides different ways of expressing an
ItemType
.

First of all, the compound symbol
item()
allows any kind of item, that is, any atomic value, or any node. (As with other compound symbols, you can use spaces before, between, or after the parentheses, but it's usually written without spaces so that's how I shall do it here.) You can combine
item()
with an occurrence indicator, so
item()
matches a single item,
item()?
matches a sequence that is either empty or contains a single item,
item()+
matches any non-empty sequence, and
item()*
matches any sequence whatsoever.

Every other way of writing the
ItemType
matches either atomic values, or nodes, but not both.

Matching Atomic Values

Matching atomic values is easy, because atomic types have names. (You can have anonymous atomic types in a schema, but there is no way to refer to them in a sequence type descriptor). If you use a
QName
as the
ItemType
, then it must be the name of a type that is known in the static context of the XPath expression, as described in Chapter 7, and this type must be an atomic type. In XSLT 2.0 this means it must either be one of the built-in types such as
xs:integer
, or a user-defined atomic type in a schema that has been imported using the

declaration.

The XSLT 2.0 specification defines a minimum set of atomic types that every processor (even one that does not support schema import) must provide, namely:

xs:anyAtomicType, xs:anyURI, xs:base64Binary, xs:boolean, xs:date, xs:dateTime, xs:dayTimeDuration, xs:decimal, xs:double, xs:duration, xs:float, xs:gDay, xs:gDayMonth, xs:gMonth, xs:gMonthDay, xs:gYear, xs:gYearMonth, xs:hexBinary, xs:integer, xs:QName, xs:string, xs:time, xs:untypedAtomic, xs:yearMonthDuration

This set was chosen because it is sufficient to allow all the functions in the core function library (that is, the functions listed in Chapter 13) to be used. Schema-aware processors, however, will support the full set of built-in types defined in XML Schema as well as user-defined types declared using

declarations in an imported schema.

Other books

Kindred of the Fallen by Isis Rushdan
AHealingCaress by Viola Grace
Blue Dragon by Kylie Chan
Nightmare Range by Martin Limon
A Forest Divided by Erin Hunter
The Betrayal by Mary Hooper