The following functions are defined to obtain information from the static or dynamic context.
Function | Meaning |
---|---|
fn:position |
Returns the context position from the dynamic context. |
fn:last |
Returns the context size from the dynamic context. |
fn:current-dateTime |
Returns the current date and time (with timezone). |
fn:current-date |
Returns the current date. |
fn:current-time |
Returns the current time. |
fn:implicit-timezone |
Returns the value of the implicit timezone property from the dynamic context. |
fn:default-collation |
Returns the value of the default collation property from the static context. |
fn:default-language |
Returns the value of the default language property from the dynamic context. |
fn:static-base-uri |
This function returns the value of the static base URI property from the static context. |
Returns the context position from the dynamic context.
fn:position () as xs:integer |
This function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.
Returns the context position from the dynamic context. (See Section C.2 Dynamic Context Components XP31.)
A dynamic error is raised [err:XPDY0002]XP if the context item is absentDM40.
Returns the context size from the dynamic context.
fn:last () as xs:integer |
This function is ·deterministic·, ·context-dependent·, and ·focus-dependent·.
Returns the context size from the dynamic context. (See Section C.2 Dynamic Context Components XP31.)
A dynamic error is raised [err:XPDY0002]XP if the context size is absentDM40.
Under most circumstances, the context size is absent only if the context item is absent. However, XSLT 3.0 with streaming defines situations in which the context item and context position are known, but the context size is unknown.
The expression (1 to 20)[fn:last() - 1]
returns 19
.
Returns the current date and time (with timezone).
fn:current-dateTime () as xs:dateTimeStamp |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.
Returns the current dateTime (with timezone) from the dynamic context. (See Section
C.2 Dynamic Context Components
XP31.) This is an
xs:dateTime
that is current at some time during the evaluation of a
query or transformation in which fn:current-dateTime
is executed.
This function is ·deterministic·. The precise instant during the query
or transformation represented by the value of fn:current-dateTime()
is
·implementation-dependent·.
If the implementation supports data types from XSD 1.1 then the returned value will be
an instance of xs:dateTimeStamp
. Otherwise, the only guarantees are that it
will be an instance of xs:dateTime
and will have a timezone component.
The returned xs:dateTime
will always have an associated timezone, which
will always be the same as the implicit timezone in the dynamic context
fn:current-dateTime()
returns an xs:dateTimeStamp
corresponding to the current date and time. For example, a call of
fn:current-dateTime()
might return
2004-05-12T18:17:15.125Z
corresponding to the current time on May 12,
2004 in timezone Z
.
Returns the current date.
fn:current-date () as xs:date |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.
Returns xs:date(fn:current-dateTime())
. This is an xs:date
(with timezone) that is current at some time during the evaluation of a query or
transformation in which fn:current-date
is executed.
This function is ·deterministic·. The precise instant during the query
or transformation represented by the value of fn:current-date
is ·implementation-dependent·.
The returned date will always have an associated timezone, which will always be the same as the implicit timezone in the dynamic context
fn:current-date()
returns an xs:date
corresponding to the
current date. For example, a call of fn:current-date()
might return
2004-05-12+01:00
.
Returns the current time.
fn:current-time () as xs:time |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.
Returns xs:time(fn:current-dateTime())
. This is an xs:time
(with timezone) that is current at some time during the evaluation of a query or
transformation in which fn:current-time
is executed.
This function is ·deterministic·. The precise instant during the query
or transformation represented by the value of fn:current-time()
is ·implementation-dependent·.
The returned time will always have an associated timezone, which will always be the same as the implicit timezone in the dynamic context
fn:current-time()
returns an xs:time
corresponding to the
current time. For example, a call of fn:current-time()
might return
23:17:00.000-05:00
.
Returns the value of the implicit timezone property from the dynamic context.
fn:implicit-timezone () as xs:dayTimeDuration |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on implicit timezone.
Returns the value of the implicit timezone property from the dynamic context. Components of the dynamic context are described in Section C.2 Dynamic Context Components XP31.
Returns the value of the default collation property from the static context.
fn:default-collation () as xs:string |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on collations.
Returns the value of the default collation property from the static context. Components of the static context are described in Section C.1 Static Context Components XP31.
The default collation property can never be absent. If it is not explicitly defined, a
system defined default can be invoked. If this is not provided, the Unicode codepoint
collation (http://www.w3.org/2005/xpath-functions/collation/codepoint
) is
used.
Returns the value of the default language property from the dynamic context.
fn:default-language () as xs:language |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on default language.
Returns the value of the default language property from the dynamic context. Components of the dynamic context are described in Section 2.1.2 Dynamic Context XP31.
The default language property can never be absent. The functions fn:format-integer
,
fn:format-date
, fn:format-time
, and fn:format-dateTime
are defined to use the default language if no explicit language is supplied. The default language
may play a role in selection of a default collation, but this is not a requirement.
This function returns the value of the static base URI property from the static context.
fn:static-base-uri () as xs:anyURI? |
This function is ·deterministic·, ·context-dependent·, and ·focus-independent·. It depends on static base URI.
The function returns the value of the static base URI property from the static context. If the property is absent, the empty sequence is returned.
Components of the static context are described in Section 2.1.1 Static Context XP31 .
XQuery 3.0 and XSLT 3.0 give an implementation freedom to use different base URIs during
the static analysis phase and the dynamic evaluation phase, that is, for compile-time
and run-time resources respectively. This is appropriate when the implementation allows
the output of static analysis (a "compiled" query or stylesheet) to be deployed for execution
to a different location from the one where static analysis took place. In this situation, the
fn:static-base-uri
function should return a URI suitable for locating
resources needed during dynamic evaluation.