MarkLogic Server
XQUERY API DOCUMENTATION
3.2
This page was generated
January 5, 2009
5:42 PM
XQuery Built-In and Modules Function Reference

Built-In: Context

The context built-in functions are XQuery functions defined to obtain information from the dynamic context. They are defined in XQuery 1.0 and XPath 2.0 Functions and Operators.
Function Summary
fn:current-date Returns xs:date(fn:current-dateTime()).
fn:current-dateTime Returns the current dateTime value (with timezone) from the dynamic context.
fn:current-time Returns xs:time(fn:current-dateTime()).
fn:default-collation Returns the value of the default collation property from the static context.
fn:implicit-timezone Returns the value of the implicit timezone property from the dynamic context.
fn:last Returns the context size from the dynamic context.
fn:position Returns the context position from the dynamic context.
fn:static-base-uri Returns the value of the base-uri property from the static context.
Function Detail
fn:current-date( ) as xs:date
Summary:

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 *stable*. The precise instant during the query or transformation represented by the value of fn:current-date() is *implementation dependent*.

Usage Notes:

fn:current-date() returns an xs:date corresponding to the current date and time. For example, an invocation of fn:current-date() might return 2004-05-12+01:00.

Example:
fn:current-date()

=> 2006-05-25-07:00

fn:current-dateTime( ) as xs:dateTime
Summary:

Returns the current dateTime value (with timezone) from the dynamic context. (See Section C.2 Dynamic Context ComponentsXP.) 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 *stable*. The precise instant during the query or transformation represented by the value of fn:current-dateTime() is *implementation dependent*.

Usage Notes:

fn:current-dateTime() returns an xs:dateTime corresponding to the current date and time. For example, an invocation of fn:current-dateTime() might return 2004-05-12T18:17:15.125Z corresponding to the current time on May 12, 2004 in timezone Z.

Example:
fn:current-dateTime()

=> 2006-05-25T18:21:24.454-07:00

fn:current-time( ) as xs:time
Summary:

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 *stable*. The precise instant during the query or transformation represented by the value of fn:current-time() is *implementation dependent*.

Usage Notes:

fn:current-time() returns an xs:time corresponding to the current date and time. For example, an invocation of fn:current-time() might return 23:17:00.000-05:00.

Example:
fn:current-time()

=> 18:24:06-07:00

fn:default-collation( ) as xs:string
Summary:

Returns the value of the default collation property from the static context. Components of the static context are discussed in Section C.1 Static Context Components[XP].

Note: The default collation property can never be undefined. If it is not explicitly defined, a system defined default can be invoked. If this is not provided, the Unicode code point collation (http://www.w3.org/2005/04/xpath-functions/collation/codepoint) is used.


Example:
fn:default-collation()

=> http://www.w3.org/2003/05/xpath-functions/collation/codepoint

fn:implicit-timezone( ) as xs:dayTimeDuration
Summary:

Returns the value of the implicit timezone property from the dynamic context. Components of the dynamic context are discussed in Section C.2 Dynamic Context Components[XP].

Example:
fn:implicit-timezone()

=> -PT7H

fn:last( ) as xs:integer
Summary:

Returns the context size from the dynamic context. (See Section C.2 Dynamic Context Components[XP].) If the context item is undefined, an error is raised [err:FONC0001].

Example:
let $x := (10, 20, 30, 40, 50)
return
$x[last()]

=> 50, which is the last item in the sequence

fn:position( ) as xs:integer
Summary:

Returns the context position from the dynamic context. (See Section C.2 Dynamic Context Components[XP].) If the context item is undefined, an error is raised [err:FONC0001].

Example:
let $x := (10, 20, 30, 40, 50)
return
$x[position() eq 2]

=> 20, which is in the second position in the sequence

fn:static-base-uri( ) as xs:anyURI?
Summary:

Returns the value of the base-uri property from the static context. If the base-uri property is undefined, the empty sequence is returned. Components of the static context are discussed in Section C.1 Static Context Components[XP].