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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
9.59Mb size Format: txt, pdf, ePub
xs:date
In most cases it is likely that
xs:date
values will be stored without a timezone, in which case the test whether two dates are equal is straightforward. If a date does have a timezone, then it is a significant part of the value. Dates are equal if their starting instants are simultaneous, which will normally happen only if they have the same timezone (the exception occurs near the International Date Line— today's date in timezone −12:00 compares equal with tomorrow's date in timezone +12:00). If one date has a timezone and the other does not, the implicit timezone is used in the comparison in the same way as for
xs:dateTime
values. This happens whenever you compare the result of
current-date()
with a simple date such as
2008-01-01
—the implicit timezone is used for the simple date, and this is always the same as the timezone used by the
current-date()
function.
xs:time
Values of type
xs:time
are considered to represent times on the same day, and are then compared in the same way as
xs:dateTime
values. This means, for example, that
02:00:00Z
and
21:00:00-05:00
(2 a.m. in London and 9 p.m. in New York) are considered not equal—they are 24 hours apart.
xs:gYear
xs:gYearMonth
xs:gMonth
xs:gMonthDay
xs:gDay
Values of these types are comparable only with other values of the same type. Since all of these types allow an optional timezone, they follow the same rules as
xs:date
. In fact, one way of defining equality is by converting the values to
xs:date
values by supplying arbitrary values for the missing components and then comparing the resulting dates.
xs:QName
Two
xs:QName
values are equal if they have the same namespace URI (or if both have no namespace URI) and if they have the same local name. Both the URI and the local name are compared in terms of Unicode codepoints, no collation is used. The prefix part, if any, is ignored.
xs:base64Binary
xs:hexBinary
Although these two types share the same value space, it is not possible to compare one with the other directly: you have to cast the value first. For each of the types, values are equal if they consist of the same sequence of octets.
xs:NOTATION
The value space of
xs:NOTATION
is the same as the value space of
xs:QName
and
xs:NOTATION
values are compared in the same way as
xs:QName
values. However, you cannot compare an
xs:QName
to an
xs:NOTATION
.
xs:duration
An
xs:duration
value is considered to comprise an integer number of months plus a decimal number of seconds. Two durations are considered equal if the months parts are equal and the seconds parts are equal. This means, for example, that
PT1H
equals
PT60M
. It also means that the zero-length
xs:yearMonthDuration
is equal to the zero-length
xs:dayTimeDuration
.

The
ne
operator is the exact inverse of
eq
: if an
eq
comparison raises an error, then
ne
also raises an error; if
eq
returns true, then
ne
returns false, and if
eq
returns false, then
ne

Other books

Convicted: A Mafia Romance by Macguire, Jacee
Erasing Faith by Julie Johnson
Unfurl by Swanson, Cidney
Lady of Avalon by Marion Zimmer Bradley, Diana L. Paxson
A Seductive Proposal by Caris Roane
Snowstop by Alan Sillitoe
A Promise of Tomorrow by Rowan McAllister