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

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

.

See Also

The Type Matching Rules
on page 219 in Chapter 5

dateTime

This function constructs an
xs:dateTime
value from a supplied
xs:date
and
xs:time
.

Signature

Argument
Type
Meaning
date
xs:date?
A supplied date
time
xs:time?
A supplied time
Result
xs:dateTime?
The
xs:dateTime
formed by combining the supplied date and time

Effect

If either of the arguments is an empty sequence, the result is an empty sequence.

Otherwise, the result is formed by combining the supplied date and time.

If neither of the arguments includes a timezone, the result will not include a timezone. If one of the arguments includes a timezone and the other does not, or if both include the same timezone, the result will have this timezone. If the two arguments both contain timezones and they are different, then an error occurs.

Note that the time value
24:00:00
is considered to represent exactly the same value as
00:00:00
(that is, midnight), and this is treated as the start of the day rather than the end.

Examples

Expression
Result
dateTime(xs:date(‘2008-01-01’), xs:time(‘12:00:00’))
2008-01-01T12:00:00
dateTime(xs:date(‘2008-01-01’), xs:time(‘12:00:00Z’))
2008-01-01T12:00:00Z
dateTime(xs:date(‘2008-01-01Z’), xs:time(‘12:00:00Z’))
2008-01-01T12:00:00Z
dateTime(xs:date(‘2008-01-01+02:00’), xs:time(‘12:00:00Z’))
Error (different timezones)
dateTime(xs:date(‘2008-01-01+02:00’), xs:time(‘24:00:00’))
2008-01-01T00:00:00+02:00

See Also

current-date()
,
-dateTime()
,
-time()
on page 738

format-date()
,
-dateTime()
,
-time()
on page 781

day-from-date, day-from-dateTime

These two functions extract the day-of-the-month component from an
xs:date
or
xs:dateTime
value. For example, on Christmas Day
day-from-date(current-date())
returns 25.

Signature

Argument
Type
Meaning
input
xs:date?
or
xs:dateTime?
The value from which a component is to be extracted. The type of the supplied argument must correspond to the type implied by the function name.
Result
xs:integer?
The day, in the range 1-31
.

Effect

The function returns the day component of the supplied
xs:date
or
xs:dateTime
. The value is used in its local timezone (not normalized to UTC). If the argument is an empty sequence, the result is an empty sequence.

Examples

Expression
Result
day-from-date(xs:date(“2008-02-28”))
28
day-from-dateTime(xs:dateTime(“2008-02-28T13:00:00”))
28
day-from-date(xs:date(“2008-07-31+01:00”))
31
day-from-dateTime(xs:dateTime(“2008-07-31T23:00:00-05:00”))
31

See Also

current-date()
,
-dateTime()
,
-time()
on page 738

format-date()
,
-dateTime()
,
-time()
on page 781

month-from-date()
,
-dateTime()
on page 833

year-from-date()
,
-dateTime()
on page 911

days-from-duration

This function extracts the value of the days component from a normalized
xs:duration
value.

Signature

Argument
Type
Meaning
input
xs:duration?
The duration whose days component is to be extracted. If an empty sequence is supplied, an empty sequence is returned.
Result
xs:integer?
The days component
.

Effect

The function returns the days component of the supplied
xs:duration
. The duration value is first normalized so that the number of hours is less than 24, the number of minutes is less than 60, and so on. However, there is never any conversion of days to months or vice versa. The result will be negative if the duration is negative.

Examples

Expression
Result
days-from-duration(xs:duration(“P5DT12H”))
5
days-from-duration(xs:dayTimeDuration(“PT72H”))
3
days-from-duration(xs:dayTimeDuration(“-P1D”))
-1
days-from-duration(xs:yearMonthDuration(“P1 M”))
0

See Also

hours-from-duration
on page 801

minutes-from-duration
on page 832

seconds-from-duration
on page 874

deep-equal

The
deep-equal()
function performs a deep comparison between two sequences:

  • The items in corresponding positions in each sequence must be deep-equal to each other.
  • If the items are nodes, they are compared by examining their children and attributes recursively.

Signature

Argument
Type
Meaning
sequence-1
item()*
The first operand of the comparison
sequence-2
item()*
The second operand of the comparison
collation
(optional)
xs:string
The collation to be used for comparing strings (at any depth)
Result
xs:boolean
True if the sequences are deep-equal; otherwise, false

Effect

This function may be used to compare:

  • Two nodes, to see whether the subtrees rooted at those nodes have identical content at every level
  • Two sequences, to see whether the items they contain are pairwise deep-equal

The function is therefore defined to operate on sequences, though in many cases it will be used to compare two singleton element or document nodes.

At the top level, two sequences are deep-equal if they have the same number of items, and if each item in the first sequence is deep-equal to the item in the corresponding position of the other sequence. A consequence of this rule is that an empty sequence is deep-equal to another empty sequence.

Where the item in a sequence is an atomic value, the corresponding item in the other sequence must also be an atomic value, and they must compare as equal using the
eq
operator, using the specified
collation
if they are strings, URIs, or untyped atomic values. If two items in corresponding positions are not comparable (for example, if one is an integer and the other is a string, or if one is a date and the other is an element node), then the function returns false; it does not report an error. Nodes are not atomized. NaN is considered to be equal to itself.

Other books

Dark Mountain by Richard Laymon
Up Over Down Under by Micol Ostow
A wasteland of strangers by Pronzini, Bill
Now Let's Talk of Graves by Sarah Shankman
Omega Force 01- Storm Force by Susannah Sandlin
The Baghdad Railway Club by Andrew Martin
Cameo Lake by Susan Wilson
Without A Clue by Wilder, Pamela