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

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

min

See
max()
on page 830

minutes-from-dateTime, minutes-from-time

The two functions
minutes-from-dateTime()
and
minutes-from-time()
extract the minutes component from an
xs:date
or
xs:dateTime
value. For example, at 16:30 local time both these functions return 30.

Signature

Argument
Type
Meaning
input
xs:time
or
xs:dateTime?
The value from which the minutes 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 minutes component, in the range 0 to 59
.

Effect

The function returns the minutes component of the supplied
xs:time
or
xs:dateTime
. The value is from the time as expressed in its local timezone (which will be the same as the minutes component of the time in UTC except in the case where the timezone offset is not a multiple of one hour).

Examples

Expression
Result
minutes-from-time(xs:time(“12:35:03.142”))
35
minutes-from-dateTime(xs:dateTime(“2008-02-28T13:55:30”))
55
minutes-from-time(xs:time(“00:30:02+01:00”))
30
minutes-from-dateTime(xs:dateTime(“2008-07-31T03:10:00+08:30”))
10

See Also

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

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

day-from-date()
,
-dateTime()
on page 744

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

minutes-from-duration

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

Signature

Argument
Type
Meaning
input
xs:duration?
The value from which the component is to be extracted. If an empty sequence is supplied, an empty sequence is returned.
Result
xs:integer?
The minutes component, in the range −59 to +59
.

Effect

The function returns the minutes 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. The result will be negative if the duration is negative.

Examples

Expression
Result
minutes-from-duration(xs:dayTimeDuration(“PT12H20 M”))
20
minutes-from-duration(xs:duration(“PT210 S”))
3
minutes-from-duration(xs:duration(“-PT75 M”))
-15
minutes-from-duration(xs:yearMonthDuration(“P1Y”))
0

See Also

days-from-duration()
on page 745

hours-from-duration()
on page 801

seconds-from-duration()
on page 874

minutes-from-time

See
minutes-from-dateTime()
on page 832.

month-from-date, month-from-dateTime

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

Signature

Argument
Type
Meaning
input
xs:date?
or
xs:dateTime?
The value whose month component is to be extracted. The type of the supplied argument must correspond to the type implied by the function name. If an empty sequence is supplied, an empty sequence is returned.
Result
xs:integer?
The month, in the range 1 (January) to 12 (December)
.

Effect

The function returns the month component of the supplied
xs:date
or
xs:dateTime
. The value is used in its local timezone (not normalized to UTC).

Examples

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

See Also

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

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

day-from-date()
,
-dateTime()
on page 744

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

months-from-duration

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

Signature

Argument
Type
Meaning
input
xs:duration?
The value from which the component is to be extracted. If an empty sequence is supplied, an empty sequence is returned.
Result
xs:integer?
The months component, in the range −11 to +11
.

Effect

The function returns the months component of the supplied
xs:duration
. The duration value is first normalized so that the number of months is less than 12. The result will be negative if the duration is negative.

Examples

Expression
Result
months-from-duration(xs:yearMonthDuration(‘P1Y3 M’))
3
months-from-duration(xs:yearMonthDuration(‘P15 M’))
3
months-from-duration(xs:duration(‘-P1Y3 M’))
-3
months-from-duration(xs:dayTimeDuration(‘P365D’))
0

See Also

years-from-duration
on page 911

name

The
name()
function returns a string in the form of a lexical
QName
that represents the name of a node. For example, if the context node is an element named

, then the expression
name()
will return the string
ms:schema
.

Changes in 2.0

Under XPath 2.0 it is an error to supply a sequence containing more than one node, unless running in backward-compatibility mode.

The data model now retains the namespace prefix, so the prefix returned by this function is more predictable.

Signature

Argument
Type
Meaning
node
(optional)
node()?
Identifies the node whose name is required. If the argument is an empty sequence, the function returns a zero-length string. If the argument is omitted, the target node is the context node. It is then an error if there is no context item, or if the context item is not a node.
Result
xs:string
A string value: a
QName
representing the name of the target node
.

Other books

Ghostmaker by Dan Abnett
Gabriel's Story by David Anthony Durham
The Crisis by David Poyer
Fugitive pieces by Anne Michaels
Close to Spider Man by Ivan E. Coyote
Crimson Rose by M. J. Trow