Xidel / Internet Tools function list

A partial list grouped by certain topics: Complete alphabetical list grouped by modules:

Standard XPath/XQuery functions fn:*

Namespace: http://www.w3.org/2005/xpath-functions
Prefix fn can be omitted.fn:abs($arg as numeric?) as numeric?
Returns the absolute value of $arg. See the XPath/XQuery function reference.
Examples:

The expression fn:abs(10.5) returns 10.5.

The expression fn:abs(-10.5) returns 10.5.

fn:adjust-date-to-timezone($arg as xs:date?) as xs:date?
fn:adjust-date-to-timezone($arg as xs:date?, $timezone as xs:dayTimeDuration?) as xs:date?
Adjusts an xs:date value to a specific timezone, or to no timezone at all; the result is the date in the target timezone that contains the starting instant of the supplied date. See the XPath/XQuery function reference.
Examples:

Assume the dynamic context provides an implicit timezone of -05:00 (-PT5H0M).

let $tz-10 := xs:dayTimeDuration("-PT10H")

The expression fn:adjust-date-to-timezone(xs:date("2002-03-07")) returns xs:date("2002-03-07-05:00").

The expression fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00")) returns xs:date("2002-03-07-05:00"). ($arg is converted to xs:dateTime("2002-03-07T00:00:00-07:00"). This is adjusted to the implicit timezone, giving "2002-03-07T02:00:00-05:00". ).

The expression fn:adjust-date-to-timezone(xs:date("2002-03-07"), $tz-10) returns xs:date("2002-03-07-10:00").

The expression fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00"), $tz-10) returns xs:date("2002-03-06-10:00"). ($arg is converted to the xs:dateTime "2002-03-07T00:00:00-07:00". This is adjusted to the given timezone, giving "2002-03-06T21:00:00-10:00". ).

The expression fn:adjust-date-to-timezone(xs:date("2002-03-07"), ()) returns xs:date("2002-03-07").

The expression fn:adjust-date-to-timezone(xs:date("2002-03-07-07:00"), ()) returns xs:date("2002-03-07").

fn:adjust-dateTime-to-timezone($arg as xs:dateTime?) as xs:dateTime?
fn:adjust-dateTime-to-timezone($arg as xs:dateTime?, $timezone as xs:dayTimeDuration?) as xs:dateTime?
Adjusts an xs:dateTime value to a specific timezone, or to no timezone at all. See the XPath/XQuery function reference.
Examples:

Assume the dynamic context provides an implicit timezone of -05:00 (-PT5H0M).

let $tz-10 := xs:dayTimeDuration("-PT10H")

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00')) returns xs:dateTime('2002-03-07T10:00:00-05:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00')) returns xs:dateTime('2002-03-07T12:00:00-05:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00'), $tz-10) returns xs:dateTime('2002-03-07T10:00:00-10:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'), $tz-10) returns xs:dateTime('2002-03-07T07:00:00-10:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'), xs:dayTimeDuration("PT10H")) returns xs:dateTime('2002-03-08T03:00:00+10:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T00:00:00+01:00'), xs:dayTimeDuration("-PT8H")) returns xs:dateTime('2002-03-06T15:00:00-08:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00'), ()) returns xs:dateTime('2002-03-07T10:00:00').

The expression fn:adjust-dateTime-to-timezone(xs:dateTime('2002-03-07T10:00:00-07:00'), ()) returns xs:dateTime('2002-03-07T10:00:00').

fn:adjust-time-to-timezone($arg as xs:time?) as xs:time?
fn:adjust-time-to-timezone($arg as xs:time?, $timezone as xs:dayTimeDuration?) as xs:time?
Adjusts an xs:time value to a specific timezone, or to no timezone at all. See the XPath/XQuery function reference.
Examples:

Assume the dynamic context provides an implicit timezone of -05:00 (-PT5H0M).

let $tz-10 := xs:dayTimeDuration("-PT10H")

The expression fn:adjust-time-to-timezone(xs:time("10:00:00")) returns xs:time("10:00:00-05:00").

The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00")) returns xs:time("12:00:00-05:00").

The expression fn:adjust-time-to-timezone(xs:time("10:00:00"), $tz-10) returns xs:time("10:00:00-10:00").

The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"), $tz-10) returns xs:time("07:00:00-10:00").

The expression fn:adjust-time-to-timezone(xs:time("10:00:00"), ()) returns xs:time("10:00:00").

The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"), ()) returns xs:time("10:00:00").

The expression fn:adjust-time-to-timezone(xs:time("10:00:00-07:00"), xs:dayTimeDuration("PT10H")) returns xs:time("03:00:00+10:00").

fn:analyze-string( $input as xs:string?, $pattern as xs:string) as element(fn:analyze-string-result)(: XPath/XQuery 3.0 only :)
fn:analyze-string($input as xs:string?, $pattern as xs:string, $flags as xs:string) as element(fn:analyze-string-result)(: XPath/XQuery 3.0 only :)
Analyzes a string using a regular expression, returning an XML structure that identifies which parts of the input string matched or failed to match the regular expression, and in the case of matched substrings, which substrings matched each capturing group in the regular expression. See the XPath/XQuery function reference.
Examples:

In the following examples, the result document is shown in serialized form, with whitespace between the element nodes. This whitespace is not actually present in the result.

The expression fn:analyze-string("The cat sat on the mat.", "\w+") returns (with whitespace added for legibility):

<analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions">
  <match>The</match>
  <non-match> </non-match>
  <match>cat</match>
  <non-match> </non-match>
  <match>sat</match>
  <non-match> </non-match>
  <match>on</match>
  <non-match> </non-match>
  <match>the</match>
  <non-match> </non-match>
  <match>mat</match>
  <non-match>.</non-match>
</analyze-string-result>

The expression fn:analyze-string("2008-12-03", "^(\d+)\-(\d+)\-(\d+)$") returns (with whitespace added for legibility):

<analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions">
  <match><group nr="1">2008</group>-<group nr="2">12</group>-<group nr="3">03</group></match>
</analyze-string-result>

The expression fn:analyze-string("A1,C15,,D24, X50,", "([A-Z])([0-9]+)") returns (with whitespace added for legibility):

<analyze-string-result xmlns="http://www.w3.org/2005/xpath-functions">                  
  <match><group nr="1">A</group><group nr="2">1</group></match>
  <non-match>,</non-match>
  <match><group nr="1">C</group><group nr="2">15</group></match>
  <non-match>,,</non-match>
  <match><group nr="1">D</group><group nr="2">24</group></match>
  <non-match>, </non-match>
  <match><group nr="1">X</group><group nr="2">50</group></match>
  <non-match>,</non-match>
</analyze-string-result>
fn:available-environment-variables( ) as xs:string*(: XPath/XQuery 3.0 only :)
Returns a list of environment variable names that are suitable for passing to fn:environment-variable, as a (possibly empty) sequence of strings. See the XPath/XQuery function reference.
fn:avg($arg as xs:anyAtomicType*) as xs:anyAtomicType?
Returns the average of the values in the input sequence $arg, that is, the sum of the values divided by the number of values. See the XPath/XQuery function reference.
Examples:

let $d1 := xs:yearMonthDuration("P20Y")

let $d2 := xs:yearMonthDuration("P10M")

let $seq3 := (3, 4, 5)

The expression fn:avg($seq3) returns 4.0. (The result is of type xs:decimal.).

The expression fn:avg(($d1, $d2)) returns xs:yearMonthDuration("P10Y5M").

fn:avg(($d1, $seq3)) raises a type error [err:FORG0006].

The expression fn:avg(()) returns ().

The expression fn:avg((xs:float('INF'), xs:float('-INF'))) returns xs:float('NaN').

The expression fn:avg(($seq3, xs:float('NaN'))) returns xs:float('NaN').

fn:base-uri( ) as xs:anyURI?
fn:base-uri($arg as node()?) as xs:anyURI?
Returns the base URI of a node. See the XPath/XQuery function reference.
fn:boolean($arg as item()*) as xs:boolean
Computes the effective boolean value of the sequence $arg. See the XPath/XQuery function reference.
Examples:

let $abc := ("a", "b", "")

fn:boolean($abc) raises a type error [err:FORG0006].

The expression fn:boolean($abc[1]) returns true().

The expression fn:boolean($abc[0]) returns false().

The expression fn:boolean($abc[3]) returns false().

fn:ceiling($arg as numeric?) as numeric?
Rounds $arg upwards to a whole number. See the XPath/XQuery function reference.
Examples:

The expression fn:ceiling(10.5) returns 11.

The expression fn:ceiling(-10.5) returns -10.

fn:codepoint-equal($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:boolean?
Returns true if two strings are equal, considered codepoint-by-codepoint. See the XPath/XQuery function reference.
Examples:

The expression fn:codepoint-equal("abcd", "abcd") returns true().

The expression fn:codepoint-equal("abcd", "abcd ") returns false().

The expression fn:codepoint-equal("", "") returns true().

The expression fn:codepoint-equal("", ()) returns ().

The expression fn:codepoint-equal((), ()) returns ().

fn:codepoints-to-string($arg as xs:integer*) as xs:string
Creates an xs:string from a sequence of ·codepoints·. See the XPath/XQuery function reference.
Examples:

The expression fn:codepoints-to-string((66, 65, 67, 72)) returns "BACH".

The expression fn:codepoints-to-string((2309, 2358, 2378, 2325)) returns "अशॊक".

The expression fn:codepoints-to-string(()) returns "".

The expression fn:codepoints-to-string(0) raises error FOCH0001.

fn:collection( ) as node()*
fn:collection($arg as xs:string?) as node()*
Returns a sequence of nodes representing a collection of documents indentified by a collection URI; or a default collection if no URI is supplied. See the XPath/XQuery function reference.
fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?) as xs:integer?
fn:compare($comparand1 as xs:string?, $comparand2 as xs:string?, $collation as xs:string) as xs:integer?
Returns -1, 0, or 1, depending on whether $comparand1 collates before, equal to, or after $comparand2 according to the rules of a selected collation. See the XPath/XQuery function reference.
Examples:

The expression fn:compare('abc', 'abc') returns 0.

The expression fn:compare('Strasse', 'Straße') returns 0. (Assuming the default collation includes provisions that equate "ss" and the (German) character "ß" ("sharp-s"). Otherwise, the returned value depends on the semantics of the default collation.).

The expression fn:compare('Strasse', 'Straße', 'http://example.com/deutsch') returns 0. (Assuming the collation identified by the URI http://example.com/deutsch includes provisions that equate "ss" and the (German) character "ß" ("sharp-s"). Otherwise, the returned value depends on the semantics of that collation.).

The expression fn:compare('Strassen', 'Straße') returns 1. (Assuming the default collation includes provisions that treat differences between "ss" and the (German) character "ß" ("sharp-s") with less strength than the differences between the base characters, such as the final "n". ).

fn:concat(2 to unlimited arguments)
Returns the concatenation of the string values of the arguments. See the XPath/XQuery function reference.
Examples:

The expression fn:concat('un', 'grateful') returns "ungrateful".

The expression fn:concat('Thy ', (), 'old ', "groans", "", ' ring', ' yet', ' in', ' my', ' ancient',' ears.') returns "Thy old groans ring yet in my ancient ears.".

The expression fn:concat('Ciao!',()) returns "Ciao!".

The expression fn:concat('Ingratitude, ', 'thou ', 'marble-hearted', ' fiend!') returns "Ingratitude, thou marble-hearted fiend!".

The expression fn:concat(01, 02, 03, 04, true()) returns "1234true".

The expression 10 || '/' || 6 returns "10/6".

fn:concatenate(2 arguments)
This function should be in op: not fn: and was included by accident.
Returns the concatenation of two sequences. See the XPath/XQuery function reference.
Examples:

The expression op:concatenate((1, 2, 3), (4, 5)) returns (1, 2, 3, 4, 5).

The expression op:concatenate((1, 2, 3), ()) returns (1, 2, 3).

The expression op:concatenate((), ()) returns ().

fn:contains($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean
fn:contains($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean
Returns true if the string $arg1 contains $arg2 as a substring, taking collations into account. See the XPath/XQuery function reference.
Examples:

The collation used in these examples, http://example.com/CollationA is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [Unicode Collation Algorithm].

The expression fn:contains ( "tattoo", "t") returns true().

The expression fn:contains ( "tattoo", "ttt") returns false().

The expression fn:contains ( "", ()) returns true(). (The first rule is applied, followed by the second rule.).

The expression fn:contains ( "abcdefghi", "-d-e-f-", "http://example.com/CollationA") returns true().

The expression fn:contains ( "a*b*c*d*e*f*g*h*i*", "d-ef-", "http://example.com/CollationA") returns true().

The expression fn:contains ( "abcd***e---f*--*ghi", "def", "http://example.com/CollationA") returns true().

The expression fn:contains ( (), "--***-*---", "http://example.com/CollationA") returns true(). (The second argument contains only ignorable collation units and is equivalent to the zero-length string.).

fn:count($arg as item()*) as xs:integer
Returns the number of items in a sequence. See the XPath/XQuery function reference.
Examples:

let $seq1 := ($item1, $item2)

let $seq2 := (98.5, 98.3, 98.9)

let $seq3 := ()

The expression fn:count($seq1) returns 2.

The expression fn:count($seq3) returns 0.

The expression fn:count($seq2) returns 3.

The expression fn:count($seq2[. > 100]) returns 0.

fn:current-date( ) as xs:date
Returns the current date. See the XPath/XQuery function reference.
Examples:

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.

fn:current-dateTime( ) as xs:dateTime
Returns the current date and time (with timezone). See the XPath/XQuery function reference.
Examples:

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.

fn:current-time( ) as xs:time
Returns the current time. See the XPath/XQuery function reference.
Examples:

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.

fn:data($arg as item()*) as xs:anyAtomicType*
fn:data( ) as xs:anyAtomicType*(: XPath/XQuery 3.0 only :)
Returns the result of atomizing a sequence, that is, replacing all nodes in the sequence by their typed values. See the XPath/XQuery function reference.
Examples:

The expression data(123) returns 123.

let $para :=

<para>In a hole in the ground there lived a <term author="Tolkein">hobbit</term>.</para>
            

The expression data($para) returns xs:untypedAtomic("In a hole in the ground there lived a hobbit.").

The expression data($para/term/@author) returns xs:untypedAtomic("Tolkein").

The expression data(abs#1) raises error FOTY0013.

fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?) as xs:dateTime?
Returns an xs:dateTime value created by combining an xs:date and an xs:time. See the XPath/XQuery function reference.
Examples:

The expression fn:dateTime(xs:date("1999-12-31"), xs:time("12:00:00")) returns xs:dateTime("1999-12-31T12:00:00").

The expression fn:dateTime(xs:date("1999-12-31"), xs:time("24:00:00")) returns xs:dateTime("1999-12-31T00:00:00"). (This is because "24:00:00" is an alternate lexical form for "00:00:00").

fn:day-from-date($arg as xs:date?) as xs:integer?
Returns the day component of an xs:date. See the XPath/XQuery function reference.
Examples:

The expression fn:day-from-date(xs:date("1999-05-31-05:00")) returns 31.

The expression fn:day-from-date(xs:date("2000-01-01+05:00")) returns 1.

fn:day-from-dateTime($arg as xs:dateTime?) as xs:integer?
Returns the day component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:day-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00")) returns 31.

The expression fn:day-from-dateTime(xs:dateTime("1999-12-31T20:00:00-05:00")) returns 31.

The expression fn:day-from-dateTime(fn:adjust-dateTime-to-timezone(xs:dateTime("1999-12-31T19:20:00-05:00"), xs:dayTimeDuration("PT0S"))) returns 1.

fn:days-from-duration($arg as xs:duration?) as xs:integer?
Returns the number of days in a duration. See the XPath/XQuery function reference.
Examples:

The expression fn:days-from-duration(xs:dayTimeDuration("P3DT10H")) returns 3.

The expression fn:days-from-duration(xs:dayTimeDuration("P3DT55H")) returns 5.

The expression fn:days-from-duration(xs:yearMonthDuration("P3Y5M")) returns 0.

fn:deep-equal($parameter1 as item()*, $parameter2 as item()*) as xs:boolean
fn:deep-equal($parameter1 as item()*, $parameter2 as item()*, $collation as string) as xs:boolean
This function assesses whether two sequences are deep-equal to each other. To be deep-equal, they must contain items that are pairwise deep-equal; and for two items to be deep-equal, they must either be atomic values that compare equal, or nodes of the same kind, with the same name, whose children are deep-equal. See the XPath/XQuery function reference.
Examples:

let $at :=

<attendees> <name last='Parker'
            first='Peter'/> <name last='Barker' first='Bob'/> <name last='Parker'
            first='Peter'/> </attendees>

The expression fn:deep-equal($at, $at/*) returns false().

The expression fn:deep-equal($at/name[1], $at/name[2]) returns false().

The expression fn:deep-equal($at/name[1], $at/name[3]) returns true().

The expression fn:deep-equal($at/name[1], 'Peter Parker') returns false().

fn:default-collation( ) as xs:string
Returns the value of the default collation property from the static context. See the XPath/XQuery function reference.
fn:distinct-values($arg as xs:anyAtomicType*) as xs:anyAtomicType*
fn:distinct-values($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType*
Returns the values that appear in a sequence, with duplicates eliminated. See the XPath/XQuery function reference.
Examples:

The expression fn:distinct-values((1, 2.0, 3, 2)) returns some permutation of (1, 3, 2.0).

The expression fn:distinct-values((xs:untypedAtomic("cherry"), xs:untypedAtomic("plum"), xs:untypedAtomic("plum"))) returns some permutation of (xs:untypedAtomic("cherry"), xs:untypedAtomic("plum")).

fn:doc($uri as xs:string?) as document-node()?
Retrieves a document using a URI supplied as an xs:string, and returns the corresponding document node. See the XPath/XQuery function reference.
fn:doc-available($uri as xs:string?) as xs:boolean
The function returns true if and only if the function call fn:doc($uri) would return a document node. See the XPath/XQuery function reference.
fn:document-uri($arg as node()?) as xs:anyURI?
fn:document-uri( ) as xs:anyURI?(: XPath/XQuery 3.0 only :)
Returns the URI of a resource where a document can be found, if available. See the XPath/XQuery function reference.
fn:element-with-id($arg as xs:string*) as element()*
fn:element-with-id($arg as xs:string*, $node as node()) as element()*
Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $arg. See the XPath/XQuery function reference.
Examples:

let $emp :=

            <employee xml:id="ID21256">
               <empnr>E21256</empnr>
               <first>John</first>
               <last>Brown</last>
            </employee>
         

The expression id('ID21256')/name() returns "employee". (The xml:id attribute has the is-id property, so the employee element is selected.).

The expression id('E21256')/name() returns "employee". (Assuming the empnr element is given the type xs:ID as a result of schema validation, the element will have the is-id property and is therefore its parent is selected. Note the difference from the behavior of fn:id.).

fn:empty($arg as item()*) as xs:boolean
Returns true if the argument is the empty sequence. See the XPath/XQuery function reference.
Examples:

The expression fn:empty((1,2,3)[10]) returns true().

The expression fn:empty(fn:remove(("hello", "world"), 1)) returns false().

fn:encode-for-uri($uri-part as xs:string?) as xs:string
Encodes reserved characters in a string that is intended to be used in the path segment of a URI. See the XPath/XQuery function reference.
Examples:

The expression fn:encode-for-uri("http://www.example.com/00/Weather/CA/Los%20Angeles#ocean") returns "http%3A%2F%2Fwww.example.com%2F00%2FWeather%2FCA%2FLos%2520Angeles%23ocean". (This is probably not what the user intended because all of the delimiters have been encoded.).

The expression concat("http://www.example.com/", encode-for-uri("~bébé")) returns "http://www.example.com/~b%C3%A9b%C3%A9".

The expression concat("http://www.example.com/", encode-for-uri("100% organic")) returns "http://www.example.com/100%25%20organic".

fn:ends-with($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean
fn:ends-with($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean
Returns true if the string $arg1 contains $arg2 as a trailing substring, taking collations into account. See the XPath/XQuery function reference.
Examples:

The collation used in these examples, http://example.com/CollationA is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [Unicode Collation Algorithm].

The expression fn:ends-with ( "tattoo", "tattoo") returns true().

The expression fn:ends-with ( "tattoo", "atto") returns false().

The expression fn:ends-with ((), ()) returns true().

The expression fn:ends-with ( "abcdefghi", "-g-h-i-", "http://example.com/CollationA") returns true().

The expression fn:ends-with ( "abcd***e---f*--*ghi", "defghi", "http://example.com/CollationA") returns true().

The expression fn:ends-with ( "abcd***e---f*--*ghi", "defghi", "http://example.com/CollationA") returns true().

The expression fn:ends-with ( (), "--***-*---", "http://example.com/CollationA") returns true(). (The second argument contains only ignorable collation units and is equivalent to the zero-length string.).

The expression fn:ends-with ( "abcdefghi", "ghi-", "http://example.com/CollationA") returns true().

fn:environment-variable($name as xs:string) as xs:string?(: XPath/XQuery 3.0 only :)
Returns the value of a system environment variable, if it exists. See the XPath/XQuery function reference.
fn:error( ) as none
fn:error($error as xs:QName) as none
fn:error($error as xs:QName?, $description as xs:string) as none
fn:error($error as xs:QName?, $description as xs:string, $error-object as item()*) as none
Calling the fn:error function raises an application-defined error. See the XPath/XQuery function reference.
Examples:

The expression fn:error() raises error FOER0000. (This returns the URI http://www.w3.org/2005/xqt-errors#FOER0000 (or the corresponding xs:QName) to the external processing environment, unless the error is caught using a try/catch construct in the host language.).

The expression fn:error(fn:QName('http://www.example.com/HR', 'myerr:toohighsal'), 'Does not apply because salary is too high') raises error myerr:toohighsal. (This returns http://www.example.com/HR#toohighsal and the xs:string "Does not apply because salary is too high" (or the corresponding xs:QName) to the external processing environment, unless the error is caught using a try/catch construct in the host language.).

fn:escape-html-uri($uri as xs:string?) as xs:string
Escapes a URI in the same way that HTML user agents handle attribute values expected to contain URIs. See the XPath/XQuery function reference.
Examples:

The expression fn:escape-html-uri ("http://www.example.com/00/Weather/CA/Los Angeles#ocean") returns "http://www.example.com/00/Weather/CA/Los Angeles#ocean".

The expression fn:escape-html-uri ("javascript:if (navigator.browserLanguage == 'fr') window.open('http://www.example.com/~bébé');") returns "javascript:if (navigator.browserLanguage == 'fr') window.open('http://www.example.com/~b%C3%A9b%C3%A9');".

fn:exactly-one($arg as item()*) as item()
Returns $arg if it contains exactly one item. Otherwise, raises an error. See the XPath/XQuery function reference.
fn:exists($arg as item()*) as xs:boolean
Returns true if the argument is a non-empty sequence. See the XPath/XQuery function reference.
Examples:

The expression fn:exists(fn:remove(("hello"), 1)) returns false().

The expression fn:exists(fn:remove(("hello", "world"), 1)) returns true().

fn:false( ) as xs:boolean
Returns the xs:boolean value false. See the XPath/XQuery function reference.
Examples:

The expression fn:false() returns xs:boolean(0).

fn:filter($seq as item()*, $f as function(item()) as xs:boolean) as item()*(: XPath/XQuery 3.0 only :)
Returns those items from the sequence $seq for which the supplied function $f returns true. See the XPath/XQuery function reference.
Examples:

The expression fn:filter(1 to 10, function($a) {$a mod 2 = 0}) returns (2, 4, 6, 8, 10).

fn:floor($arg as numeric?) as numeric?
Rounds $arg downwards to a whole number. See the XPath/XQuery function reference.
Examples:

The expression fn:floor(10.5) returns 10.

The expression fn:floor(-10.5) returns -11.

fn:fold-left($seq as item()*, $zero as item()*, $f as function(item()*, item()) as item()*) as item()*(: XPath/XQuery 3.0 only :)
Processes the supplied sequence from left to right, applying the supplied function repeatedly to each item in turn, together with an accumulated result value. See the XPath/XQuery function reference.
Examples:

The expression fn:fold-left(1 to 5, 0, function($a, $b) { $a + $b }) returns 15. (This returns the sum of the items in the sequence).

The expression fn:fold-left((2,3,5,7), 1, function($a, $b) { $a * $b }) returns 210. (This returns the product of the items in the sequence).

The expression fn:fold-left((true(), false(), false()), false(), function($a, $b) { $a or $b }) returns true(). (This returns true if any item in the sequence has an effective boolean value of true).

The expression fn:fold-left((true(), false(), false()), false(), function($a, $b) { $a and $b }) returns false(). (This returns true only if every item in the sequence has an effective boolean value of true).

The expression fn:fold-left(1 to 5, (), function($a, $b) {($b, $a)}) returns (5,4,3,2,1). (This reverses the order of the items in a sequence).

The expression fn:fold-left(1 to 5, "", fn:concat(?, ".", ?)) returns ".1.2.3.4.5".

The expression fn:fold-left(1 to 5, "$zero", fn:concat("$f(", ?, ", ", ?, ")") returns "$f($f($f($f($f($zero, 1), 2), 3), 4), 5)".

fn:fold-right($seq as item()*, $zero as item()*, $f as function(item(), item()*) as item()*) as item()*(: XPath/XQuery 3.0 only :)
Processes the supplied sequence from right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value. See the XPath/XQuery function reference.
Examples:

The expression fn:fold-right(1 to 5, 0, function($a, $b) { $a + $b }) returns 15. (This returns the sum of the items in the sequence).

The expression fn:fold-right(1 to 5, "", fn:concat(?, ".", ?)) returns "1.2.3.4.5.".

The expression fn:fold-right(1 to 5, "$zero", concat("$f(", ?, ", ", ?, ")")) returns "$f(1, $f(2, $f(3, $f(4, $f(5, $zero)))))".

fn:for-each($seq as item()*, $f as function(item()) as item()*) as item()*(: XPath/XQuery 3.0 only :)
Applies the function item $f to every item from the sequence $seq in turn, returning the concatenation of the resulting sequences in order. See the XPath/XQuery function reference.
Examples:

The expression fn:for-each(1 to 5, function($a) { $a * $a }) returns (1, 4, 9, 16, 25).

The expression fn:for-each(("john", "jane"), fn:string-to-codepoints#1) returns (106, 111, 104, 110, 106, 97, 110, 101).

The expression fn:for-each(("23", "29"), xs:int#1) returns (23, 29).

fn:for-each-pair($seq1 as item()*, $seq2 as item()*, $f as function(item(), item()) as item()*) as item()*(: XPath/XQuery 3.0 only :)
Applies the function item $f to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order. See the XPath/XQuery function reference.
Examples:

The expression fn:for-each-pair(("a", "b", "c"), ("x", "y", "z"), concat#2) returns ("ax", "by", "cz").

The expression fn:for-each-pair(1 to 5, 1 to 5, function($a, $b){10*$a + $b} returns (11, 22, 33, 44, 55).

fn:format-date($value as xs:date?, $picture as xs:string) as xs:string?(: XPath/XQuery 3.0 only :)
fn:format-date( $value as xs:date?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?(: XPath/XQuery 3.0 only :)
Returns a string containing an xs:date value formatted for display. See the XPath/XQuery function reference.
fn:format-dateTime($value as xs:dateTime?, $picture as xs:string) as xs:string?(: XPath/XQuery 3.0 only :)
fn:format-dateTime( $value as xs:dateTime?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?(: XPath/XQuery 3.0 only :)
Returns a string containing an xs:dateTime value formatted for display. See the XPath/XQuery function reference.
fn:format-integer($value as xs:integer?, $picture as xs:string) as xs:string(: XPath/XQuery 3.0 only :)
fn:format-integer( $value as xs:integer?, $picture as xs:string, $lang as xs:string?) as xs:string(: XPath/XQuery 3.0 only :)
Formats an integer according to a given picture string, using the conventions of a given natural language if specified. See the XPath/XQuery function reference.
Examples:

The expression format-integer(123, '0000') returns "0123".

format-integer(123, 'w') might return "one hundred and twenty-three"

The expression format-integer(21, '1;o', 'en') returns "21st".

format-integer(14, 'Ww;o(-e)', 'de') might return "Vierzehnte"

The expression format-integer(7, 'a') returns "g".

The expression format-integer(57, 'I') returns "LVII".

The expression format-integer(1234, '#;##0;') returns "1;234".

fn:format-number($value as xs:numeric?, $picture as xs:string) as xs:string(: XPath/XQuery 3.0 only :)
fn:format-number( $value as xs:numeric?, $picture as xs:string, $decimal-format-name as xs:string?) as xs:string(: XPath/XQuery 3.0 only :)
Returns a string containing a number formatted according to a given picture string, taking account of decimal formats specified in the static context. See the XPath/XQuery function reference.
Examples:

The following examples assume a default decimal format in which the chosen digits are the ASCII digits 0-9, the decimal separator is ".", the grouping separator is ",", the minus-sign is "-", the percent-sign is "%", and the exponent separator is "e".

The expression format-number(12345.6, '#,###.00') returns "12,345.60".

The expression format-number(12345678.9, '9,999.99') returns "12,345,678.90".

The expression format-number(123.9, '9999') returns "0124".

The expression format-number(0.14, '01%') returns "14%".

The expression format-number(-6, '000') returns "-006".

The expression format-number(12.34, '0.000e00') returns "1.234e01".

The expression format-number(12.34, '#.000e0') returns "0.123e2".

The following example assumes the existence of a decimal format named 'ch' in which the grouping separator is ʹ and the decimal separator is ·:

The expression format-number(1234.5678, '#ʹ##0·00', 'ch') returns "1ʹ234·57".

fn:format-time($value as xs:time?, $picture as xs:string) as xs:string?(: XPath/XQuery 3.0 only :)
fn:format-time( $value as xs:time?, $picture as xs:string, $language as xs:string?, $calendar as xs:string?, $place as xs:string?) as xs:string?(: XPath/XQuery 3.0 only :)
Returns a string containing an xs:time value formatted for display. See the XPath/XQuery function reference.
fn:function-arity($func as function(*)) as xs:integer(: XPath/XQuery 3.0 only :)
Returns the arity of the function identified by a function item. See the XPath/XQuery function reference.
Examples:

The expression fn:function-arity(fn:substring#2) returns 2.

The expression fn:function-arity(function($node){name($node)}) returns 1.

The expression let $initial := fn:substring(?, 1, 1) return fn:function-arity($initial) returns 1.

fn:function-lookup($name as xs:QName, $arity as xs:integer) as function(*)?(: XPath/XQuery 3.0 only :)
Returns the function having a given name and arity, if there is one. See the XPath/XQuery function reference.
Examples:

The expression fn:function-lookup(xs:QName('fn:substring'), 2)('abcd', 2) returns 'bcd'.

The expression (fn:function-lookup(xs:QName('xs:dateTimeStamp'), 1), xs:dateTime#1)[1] ('2011-11-11T11:11:11Z') returns an xs:dateTime value set to the specified date, time, and timezone; if the implementation supports XSD 1.1 then the result will be an instance of the derived type xs:dateTimeStamp. The query is written to ensure that no failure occurs when the implementation does not recognize the type xs:dateTimeStamp.

The expression (let $f := fn:function-lookup(xs:QName('zip:binary-entry', 2) return if (exists($f)) then $f($href, $entry) else () returns the result of calling zip:binary-entry($href, $entry) if the function is available, or an empty sequence otherwise.

fn:function-name($func as function(*)) as xs:QName?(: XPath/XQuery 3.0 only :)
Returns the name of the function identified by a function item. See the XPath/XQuery function reference.
Examples:

The expression fn:function-name(fn:substring#2) returns fn:QName("http://www.w3.org/2005/xpath-functions", "fn:substring"). (The namespace prefix of the returned QName is not predictable.).

The expression fn:function-name(function($node){count($node/*)}) returns ().

fn:generate-id( ) as xs:string(: XPath/XQuery 3.0 only :)
fn:generate-id($arg as node()?) as xs:string(: XPath/XQuery 3.0 only :)
This function returns a string that uniquely identifies a given node. See the XPath/XQuery function reference.
Examples:

The primary use case for this function is to generate hyperlinks. For example, when generating HTML, an anchor for a given section $sect can be generated by writing (in either XSLT or XQuery):

<a name="{generate-id($sect)}"/>

and a link to that section can then be produced with code such as:

see <a href="#{generate-id($sect)}">here</a>

Note that anchors generated in this way will not necessarily be the same each time a document is republished.

fn:has-children( ) as xs:boolean(: XPath/XQuery 3.0 only :)
fn:has-children($node as node()?) as xs:boolean(: XPath/XQuery 3.0 only :)
Returns true if the supplied node has one or more child nodes (of any kind). See the XPath/XQuery function reference.
fn:head($arg as item()*) as item()?(: XPath/XQuery 3.0 only :)
Returns the first item in a sequence. See the XPath/XQuery function reference.
Examples:

The expression fn:head(1 to 5) returns 1.

The expression fn:head(("a", "b", "c")) returns "a".

The expression fn:head(()) returns ().

fn:hours-from-dateTime($arg as xs:dateTime?) as xs:integer?
Returns the hours component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:hours-from-dateTime(xs:dateTime("1999-05-31T08:20:00-05:00")) returns 8.

The expression fn:hours-from-dateTime(xs:dateTime("1999-12-31T21:20:00-05:00")) returns 21.

The expression fn:hours-from-dateTime(fn:adjust-dateTime-to-timezone(xs:dateTime("1999-12-31T21:20:00-05:00"), xs:dayTimeDuration("PT0S"))) returns 2.

The expression fn:hours-from-dateTime(xs:dateTime("1999-12-31T12:00:00")) returns 12.

The expression fn:hours-from-dateTime(xs:dateTime("1999-12-31T24:00:00")) returns 0.

fn:hours-from-duration($arg as xs:duration?) as xs:integer?
Returns the number of hours in a duration. See the XPath/XQuery function reference.
Examples:

The expression fn:hours-from-duration(xs:dayTimeDuration("P3DT10H")) returns 10.

The expression fn:hours-from-duration(xs:dayTimeDuration("P3DT12H32M12S")) returns 12.

The expression fn:hours-from-duration(xs:dayTimeDuration("PT123H")) returns 3.

The expression fn:hours-from-duration(xs:dayTimeDuration("-P3DT10H")) returns -10.

fn:hours-from-time($arg as xs:time?) as xs:integer?
Returns the hours component of an xs:time. See the XPath/XQuery function reference.
Examples:

Assume that the dynamic context provides an implicit timezone value of -05:00.

The expression fn:hours-from-time(xs:time("11:23:00")) returns 11.

The expression fn:hours-from-time(xs:time("21:23:00")) returns 21.

The expression fn:hours-from-time(xs:time("01:23:00+05:00")) returns 1.

The expression fn:hours-from-time(fn:adjust-time-to-timezone(xs:time("01:23:00+05:00"), xs:dayTimeDuration("PT0S"))) returns 20.

The expression fn:hours-from-time(xs:time("24:00:00")) returns 0.

fn:id($arg as xs:string*) as element()*
fn:id($arg as xs:string*, $node as node()) as element()*
Returns the sequence of element nodes that have an ID value matching the value of one or more of the IDREF values supplied in $arg. See the XPath/XQuery function reference.
Examples:

let $emp :=

            <employee xml:id="ID21256">
               <empnr>E21256</empnr>
               <first>John</first>
               <last>Brown</last>
            </employee>
         

The expression id('ID21256')/name() returns employee. (The xml:id attribute has the is-id property, so the employee element is selected.).

The expression id('E21256')/name() returns empnr. (Assuming the empnr element is given the type xs:ID as a result of schema validation, the element will have the is-id property and is therefore selected. Note the difference from the behavior of fn:element-with-id.).

fn:idref($arg as xs:string*) as node()*
fn:idref($arg as xs:string*, $node as node()) as node()*
Returns the sequence of element or attribute nodes with an IDREF value matching the value of one or more of the ID values supplied in $arg. See the XPath/XQuery function reference.
fn:implicit-timezone( ) as xs:dayTimeDuration
Returns the value of the implicit timezone property from the dynamic context. See the XPath/XQuery function reference.
fn:in-scope-prefixes($element as element()) as xs:string*
Returns the prefixes of the in-scope namespaces for an element node. See the XPath/XQuery function reference.
fn:index-of($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType) as xs:integer*
fn:index-of($seqParam as xs:anyAtomicType*, $srchParam as xs:anyAtomicType, $collation as xs:string) as xs:integer*
Returns a sequence of positive integers giving the positions within the sequence $seq of items that are equal to $search. See the XPath/XQuery function reference.
Examples:

The expression fn:index-of((10, 20, 30, 40), 35) returns ().

The expression fn:index-of((10, 20, 30, 30, 20, 10), 20) returns (2, 5).

The expression fn:index-of(("a", "sport", "and", "a", "pastime"), "a") returns (1, 4).

The expression fn:index-of(current-date(), 23) returns ().

If @a is an attribute of type xs:NMTOKENS whose string value is "red green blue", and whose typed value is therefore ("red", "green", "blue"), then fn:index-of(@a, "blue") returns 3. This is because the function calling mechanism atomizes the attribute node to produce a sequence of three xs:NMTOKEN values.

fn:innermost($nodes as node()*) as node()*(: XPath/XQuery 3.0 only :)
Returns every node within the input sequence that is not an ancestor of another member of the input sequence; the nodes are returned in document order with duplicates eliminated. See the XPath/XQuery function reference.
Examples:

If the source document contains nested sections represented by div elements, the expression innermost(//div) returns those div elements that do not contain further div elements.

fn:insert-before($target as item()*, $position as xs:integer, $inserts as item()*) as item()*
Returns a sequence constructed by inserting an item or a sequence of items at a given position within an existing sequence. See the XPath/XQuery function reference.
Examples:

let $abc := ("a", "b", "c")

The expression fn:insert-before($abc, 0, "z") returns ("z", "a", "b", "c").

The expression fn:insert-before($abc, 1, "z") returns ("z", "a", "b", "c").

The expression fn:insert-before($abc, 2, "z") returns ("a", "z", "b", "c").

The expression fn:insert-before($abc, 3, "z") returns ("a", "b", "z", "c").

The expression fn:insert-before($abc, 4, "z") returns ("a", "b", "c", "z").

fn:iri-to-uri($iri as xs:string?) as xs:string
Converts a string containing an IRI into a URI according to the rules of [RFC 3987]. See the XPath/XQuery function reference.
Examples:

The expression fn:iri-to-uri ("http://www.example.com/00/Weather/CA/Los%20Angeles#ocean") returns "http://www.example.com/00/Weather/CA/Los%20Angeles#ocean".

The expression fn:iri-to-uri ("http://www.example.com/~bébé") returns "http://www.example.com/~b%C3%A9b%C3%A9".

fn:lang($testlang as xs:string?) as xs:boolean
fn:lang($testlang as xs:string?, $node as node()) as xs:boolean
This function tests whether the language of $node, or the context item if the second argument is omitted, as specified by xml:lang attributes is the same as, or is a sublanguage of, the language specified by $testlang. See the XPath/XQuery function reference.
Examples:

The expression fn:lang("en") would return true if the context node were any of the following four elements:

The expression fn:lang("fr") would return false if the context node were <para xml:lang="EN"/>

fn:last( ) as xs:integer
Returns the context size from the dynamic context. See the XPath/XQuery function reference.
Examples:

The expression (1 to 20)[fn:last() - 1] returns 19.

fn:local-name( ) as xs:string
fn:local-name($arg as node()?) as xs:string
Returns the local part of the name of $arg as an xs:string that is either the zero-length string, or has the lexical form of an xs:NCName. See the XPath/XQuery function reference.
fn:local-name-from-QName($arg as xs:QName?) as xs:NCName?
Returns the local part of the supplied QName. See the XPath/XQuery function reference.
Examples:

The expression fn:local-name-from-QName(fn:QName("http://www.example.com/example", "person")) returns "person".

fn:lower-case($arg as xs:string?) as xs:string
Converts a string to lower case. See the XPath/XQuery function reference.
Examples:

The expression fn:lower-case("ABc!D") returns "abc!d".

fn:matches($input as xs:string?, $pattern as xs:string) as xs:boolean
fn:matches($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:boolean
Returns true if the supplied string matches a given regular expression. See the XPath/XQuery function reference.
Examples:

The expression fn:matches("abracadabra", "bra") returns true().

The expression fn:matches("abracadabra", "^a.*a$") returns true().

The expression fn:matches("abracadabra", "^bra") returns false().

Given the source document:

let $poem :=

<poem author="Wilhelm Busch"> 
Kaum hat dies der Hahn gesehen, 
Fängt er auch schon an zu krähen: 
Kikeriki! Kikikerikih!! 
Tak, tak, tak! - da kommen sie. 
</poem>

the following function calls produce the following results, with the poem element as the context node:

The expression fn:matches($poem, "Kaum.*krähen") returns false().

The expression fn:matches($poem, "Kaum.*krähen", "s") returns true().

The expression fn:matches($poem, "^Kaum.*gesehen,$", "m") returns true().

The expression fn:matches($poem, "^Kaum.*gesehen,$") returns false().

The expression fn:matches($poem, "kiki", "i") returns true().

fn:max($arg as xs:anyAtomicType*) as xs:anyAtomicType?
fn:max($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?
Returns a value that is equal to the highest value appearing in the input sequence. See the XPath/XQuery function reference.
Examples:

The expression fn:max((3,4,5)) returns 5.

The expression fn:max((xs:integer(5), xs:float(5.0), xs:double(0))) returns xs:double(5.0e0).

fn:max((3,4,"Zero")) raises a type error [err:FORG0006].

The expression fn:max((fn:current-date(), xs:date("2100-01-01"))) returns xs:date("2100-01-01"). (Assuming that the current date is during the 21st century.).

The expression fn:max(("a", "b", "c")) returns "c". (Assuming a typical default collation.).

fn:min($arg as xs:anyAtomicType*) as xs:anyAtomicType?
fn:min($arg as xs:anyAtomicType*, $collation as string) as xs:anyAtomicType?
Returns a value that is equal to the lowest value appearing in the input sequence. See the XPath/XQuery function reference.
Examples:

The expression fn:min((3,4,5)) returns 3.

The expression fn:min((xs:integer(5), xs:float(5), xs:double(10))) returns xs:double(5.0e0).

fn:min((3,4,"Zero")) raises a type error [err:FORG0006].

fn:min((xs:float(0.0E0), xs:float(-0.0E0))) can return either positive or negative zero. The two items are equal, so it is ·implementation dependent· which is returned.

The expression fn:min((fn:current-date(), xs:date("1900-01-01"))) returns xs:date("1900-01-01"). (Assuming that the current date is set to a reasonable value.).

The expression fn:min(("a", "b", "c")) returns "a". (Assuming a typical default collation.).

fn:minutes-from-dateTime($arg as xs:dateTime?) as xs:integer?
Returns the minute component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:minutes-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00")) returns 20.

The expression fn:minutes-from-dateTime(xs:dateTime("1999-05-31T13:30:00+05:30")) returns 30.

fn:minutes-from-duration($arg as xs:duration?) as xs:integer?
Returns the number of minutes in a duration. See the XPath/XQuery function reference.
Examples:

The expression fn:minutes-from-duration(xs:dayTimeDuration("P3DT10H")) returns 0.

The expression fn:minutes-from-duration(xs:dayTimeDuration("-P5DT12H30M")) returns -30.

fn:minutes-from-time($arg as xs:time?) as xs:integer?
Returns the minutes component of an xs:time. See the XPath/XQuery function reference.
Examples:

The expression fn:minutes-from-time(xs:time("13:00:00Z")) returns 0.

fn:month-from-date($arg as xs:date?) as xs:integer?
Returns the month component of an xs:date. See the XPath/XQuery function reference.
Examples:

The expression fn:month-from-date(xs:date("1999-05-31-05:00")) returns 5.

The expression fn:month-from-date(xs:date("2000-01-01+05:00")) returns 1.

fn:month-from-dateTime($arg as xs:dateTime?) as xs:integer?
Returns the month component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:month-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00")) returns 5.

The expression fn:month-from-dateTime(xs:dateTime("1999-12-31T19:20:00-05:00")) returns 12.

The expression fn:month-from-dateTime(fn:adjust-dateTime-to-timezone(xs:dateTime("1999-12-31T19:20:00-05:00"), xs:dayTimeDuration("PT0S"))) returns 1.

fn:months-from-duration($arg as xs:duration?) as xs:integer?
Returns the number of months in a duration. See the XPath/XQuery function reference.
Examples:

The expression fn:months-from-duration(xs:yearMonthDuration("P20Y15M")) returns 3.

The expression fn:months-from-duration(xs:yearMonthDuration("-P20Y18M")) returns -6.

The expression fn:months-from-duration(xs:dayTimeDuration("-P2DT15H0M0S")) returns 0.

fn:name( ) as xs:string
fn:name($arg as node()?) as xs:string
Returns the name of a node, as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName. See the XPath/XQuery function reference.
fn:namespace-uri( ) as xs:anyURI
fn:namespace-uri($arg as node()?) as xs:anyURI
Returns the namespace URI part of the name of $arg, as an xs:anyURI value. See the XPath/XQuery function reference.
fn:namespace-uri-for-prefix($prefix as xs:string?, $element as element()) as xs:anyURI?
Returns the namespace URI of one of the in-scope namespaces for $element, identified by its namespace prefix. See the XPath/XQuery function reference.
Examples:

let $e :=

<z:a xmlns="http://example.org/one" xmlns:z="http://example.org/two">
  <b xmlns=""/>
</z:a>

The expression fn:namespace-uri-for-prefix("z", $e) returns "http://example.org/two".

The expression fn:namespace-uri-for-prefix("", $e) returns "http://example.org/one".

The expression fn:namespace-uri-for-prefix((), $e) returns "http://example.org/one".

The expression fn:namespace-uri-for-prefix("xml", $e) returns "http://www.w3.org/XML/1998/namespace".

The expression fn:namespace-uri-for-prefix("xml", $e) returns "http://www.w3.org/XML/1998/namespace".

fn:namespace-uri-from-QName($arg as xs:QName?) as xs:anyURI?
Returns the namespace URI part of the supplied QName. See the XPath/XQuery function reference.
Examples:

The expression fn:namespace-uri-from-QName(fn:QName("http://www.example.com/example", "person")) returns xs:anyURI("http://www.example.com/example").

fn:nilled($arg as node()?) as xs:boolean?
fn:nilled( ) as xs:boolean(: XPath/XQuery 3.0 only :)
Returns true for an element that is nilled. See the XPath/XQuery function reference.
fn:node-name($arg as node()?) as xs:QName?
fn:node-name( ) as xs:QName?(: XPath/XQuery 3.0 only :)
Returns the name of a node, as an xs:QName. See the XPath/XQuery function reference.
fn:normalize-space( ) as xs:string
fn:normalize-space($arg as xs:string?) as xs:string
Returns the value of $arg with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character. See the XPath/XQuery function reference.
Examples:

The expression fn:normalize-space(" The    wealthy curled darlings                                         of    our    nation. ") returns "The wealthy curled darlings of our nation.".

The expression fn:normalize-space(()) returns "".

fn:normalize-unicode($arg as xs:string?) as xs:string
fn:normalize-unicode($arg as string?, $normalizationForm as xs:string) as xs:string
Returns the value of $arg after applying Unicode normalization. See the XPath/XQuery function reference.
fn:not($arg as item()*) as xs:boolean
Returns true if the effective boolean value of $arg is false, or false if it is true. See the XPath/XQuery function reference.
Examples:

The expression fn:not(fn:true()) returns false().

The expression fn:not("false") returns false().

fn:number( ) as xs:double
fn:number($arg as xs:anyAtomicType?) as xs:double
Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double. See the XPath/XQuery function reference.
Examples:

The expression fn:number($item1/quantity) returns 5.0e0.

The expression fn:number($item2/description) returns xs:double('NaN').

Assume that the context item is the xs:string value "15". Then fn:number() returns 1.5e1.

fn:one-or-more($arg as item()*) as item()+
Returns $arg if it contains one or more items. Otherwise, raises an error. See the XPath/XQuery function reference.
fn:outermost($nodes as node()*) as node()*(: XPath/XQuery 3.0 only :)
Returns every node within the input sequence that has no ancestor that is itself a member of the input sequence; the nodes are returned in document order with duplicates eliminated. See the XPath/XQuery function reference.
Examples:

If the source document contains nested sections represented by div elements, the expression outermost(//div) returns those div elements that are not contained within further div elements.

fn:parse-xml($arg as xs:string?) as document-node(element(*)) ?(: XPath/XQuery 3.0 only :)
This function takes as input an XML document represented as a string, and returns the document node at the root of an XDM tree representing the parsed document. See the XPath/XQuery function reference.
Examples:

The expression fn:parse-xml("<alpha>abcd</alpha>") returns a newly created document node, having an alpha element as its only child; the alpha element in turn is the parent of a text node whose string value is "abcd".

fn:parse-xml-fragment($arg as xs:string?) as document-node(element(*)) ?(: XPath/XQuery 3.0 only :)
This function takes as input an XML external entity represented as a string, and returns the document node at the root of an XDM tree representing the parsed document fragment. See the XPath/XQuery function reference.
Examples:

The expression fn:parse-xml-fragment("<alpha>abcd</alpha><beta>abcd</beta>") returns a newly created document node, having two elements named alpha and beta as its children; each of these elements in turn is the parent of a text node.

The expression fn:parse-xml-fragment("He was <i>so</i> kind") returns a newly created document node having three children: a text node whose string value is "He was ", an element node named i having a child text node with string value "so", and a text node whose string value is " kind".

The expression fn:parse-xml-fragment("") returns a document node having no children.

The expression fn:parse-xml-fragment(" ") returns a document node whose children comprise a single text node whose string value is a single space.

The expression fn:parse-xml-fragment('<xml version="1.0" encoding="utf8" standalone="yes"?></a>") results in a dynamic error [err:FODC0006] because the "standalone" keyword is not permitted in the text declaration that appears at the start of an external general parsed entity. (Thus, it is not the case that any input accepted by the fn:parse-xml function will also be accepted by fn:parse-xml-fragment.)

fn:path( ) as xs:string?(: XPath/XQuery 3.0 only :)
fn:path($arg as node()?) as xs:string?(: XPath/XQuery 3.0 only :)
Returns a path expression that can be used to select the supplied node relative to the root of its containing document. See the XPath/XQuery function reference.
Examples:

let $e :=

fn:parse-xml('<?xml version="1.0"?>
<p xmlns="http://example.com/one" xml:lang="de" author="Friedrich von Schiller">
Freude, schöner Götterfunken,<br/>
Tochter aus Elysium,<br/>
Wir betreten feuertrunken,<br/>
Himmlische, dein Heiligtum.</p>')
         

The expression fn:path($e) returns '/'.

The expression fn:path($e/*:p) returns '/Q{http://example.com/one}p[1]'.

The expression fn:path($e/*:p/@xml:lang) returns '/Q{http://example.com/one}p[1]/@Q{http://www.w3.org/XML/1998/namespace}lang'.

The expression fn:path($e/*:p/@author) returns '/Q{http://example.com/one}p[1]/@author'.

The expression fn:path($e/*:p/*:br[2]) returns '/Q{http://example.com/one}p[1]/Q{http://example.com/one}br[2]'.

The expression fn:path($e//text()[starts-with(normalize-space(), 'Tochter')]) returns '/Q{http://example.com/one}p[1]/text()[2]'.

let $emp :=

            <employee xml:id="ID21256">
               <empnr>E21256</empnr>
               <first>John</first>
               <last>Brown</last>
            </employee>
         

The expression fn:path($emp) returns 'Q{http://www.w3.org/2005/xpath-functions}root()'.

The expression fn:path($emp/@xml:id) returns 'Q{http://www.w3.org/2005/xpath-functions}root()/@Q{http://www.w3.org/XML/1998/namespace}id'.

The expression fn:path($emp/empnr) returns 'Q{http://www.w3.org/2005/xpath-functions}root()/Q{}empnr[1]'.

fn:position( ) as xs:integer
Returns the context position from the dynamic context. See the XPath/XQuery function reference.
fn:prefix-from-QName($arg as xs:QName?) as xs:NCName?
Returns the prefix component of the supplied QName. See the XPath/XQuery function reference.
fn:QName($paramURI as xs:string?, $paramQName as xs:string) as xs:QName
Constructs an xs:QName value given a namespace URI and a lexical QName. See the XPath/XQuery function reference.
Examples:

fn:QName("http://www.example.com/example", "person") returns an xs:QName with namespace URI = "http://www.example.com/example", local name = "person" and prefix = "".

fn:QName("http://www.example.com/example", "ht:person") returns an xs:QName with namespace URI = "http://www.example.com/example", local name = "person" and prefix = "ht".

fn:remove($target as item()*, $position as xs:integer) as item()*
Returns a new sequence containing all the items of $target except the item at position $position. See the XPath/XQuery function reference.
Examples:

let $abc := ("a", "b", "c")

The expression fn:remove($abc, 0) returns ("a", "b", "c").

The expression fn:remove($abc, 1) returns ("b", "c").

The expression fn:remove($abc, 6) returns ("a", "b", "c").

The expression fn:remove((), 3) returns ().

fn:replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string) as xs:string
fn:replace($input as xs:string?, $pattern as xs:string, $replacement as xs:string, $flags as xs:string) as xs:string
Returns a string produced from the input string by replacing any substrings that match a given regular expression with a supplied replacement string. See the XPath/XQuery function reference.
Examples:

The expression replace("abracadabra", "bra", "*") returns "a*cada*".

The expression replace("abracadabra", "a.*a", "*") returns "*".

The expression replace("abracadabra", "a.*?a", "*") returns "*c*bra".

The expression replace("abracadabra", "a", "") returns "brcdbr".

The expression replace("abracadabra", "a(.)", "a$1$1") returns "abbraccaddabbra".

The expression replace("abracadabra", ".*?", "$1") raises an error, because the pattern matches the zero-length string

The expression replace("AAAA", "A+", "b") returns "b".

The expression replace("AAAA", "A+?", "b") returns "bbbb".

The expression replace("darted", "^(.*?)d(.*)$", "$1c$2") returns "carted". (The first d is replaced.).

fn:resolve-QName($qname as xs:string?, $element as element()) as xs:QName?
Returns an xs:QName value (that is, an expanded-QName) by taking an xs:string that has the lexical form of an xs:QName (a string in the form "prefix:local-name" or "local-name") and resolving it using the in-scope namespaces for a given element. See the XPath/XQuery function reference.
Examples:

Assume that the element bound to $element has a single namespace binding bound to the prefix eg.

fn:resolve-QName("hello", $element) returns a QName with local name "hello" that is in no namespace.

fn:resolve-QName("eg:myFunc", $element) returns an xs:QName whose namespace URI is specified by the namespace binding corresponding to the prefix "eg" and whose local name is "myFunc".

fn:resolve-uri($relative as xs:string?) as xs:anyURI?
fn:resolve-uri($relative as xs:string?, $base as xs:string) as xs:anyURI?
Resolves a relative IRI reference against an absolute IRI. See the XPath/XQuery function reference.
fn:reverse($arg as item()*) as item()*
Reverses the order of items in a sequence. See the XPath/XQuery function reference.
Examples:

let $abc := ("a", "b", "c")

The expression fn:reverse($abc) returns ("c", "b", "a").

The expression fn:reverse(("hello")) returns ("hello").

The expression fn:reverse(()) returns ().

fn:root( ) as node()
fn:root($arg as node()?) as node()?
Returns the root of the tree to which $arg belongs. This will usually, but not necessarily, be a document node. See the XPath/XQuery function reference.
Examples:

These examples use some variables which could be defined in [XQuery 1.0: An XML Query Language] as:

let $i := <tool>wrench</tool>
let $o := <order> {$i} <quantity>5</quantity> </order>
let $odoc := document {$o}
let $newi := $o/tool

Or they could be defined in [XSL Transformations (XSLT) Version 2.0] as:

<xsl:variable name="i" as="element()">
  <tool>wrench</tool>
</xsl:variable>

<xsl:variable name="o" as="element()">
  <order>
    <xsl:copy-of select="$i"/>
    <quantity>5</quantity>
  </order>
</xsl:variable>

<xsl:variable name="odoc">
  <xsl:copy-of select="$o"/>
</xsl:variable>

<xsl:variable name="newi" select="$o/tool"/>

fn:root($i) returns the element node $i

fn:root($o/quantity) returns the element node $o

fn:root($odoc//quantity) returns the document node $odoc

fn:root($newi) returns the element node $o

The final three examples could be made type-safe by wrapping their operands with fn:exactly-one().

fn:round($arg as numeric?) as numeric?
fn:round($arg as numeric?, $precision as xs:integer) as numeric?(: XPath/XQuery 3.0 only :)
Rounds a value to a specified number of decimal places, rounding upwards if two such values are equally near. See the XPath/XQuery function reference.
Examples:

The expression fn:round(2.5) returns 3.0.

The expression fn:round(2.4999) returns 2.0.

The expression fn:round(-2.5) returns -2.0. (Not the possible alternative, -3).

The expression fn:round(1.125, 2) returns 1.13.

The expression fn:round(8452, -2) returns 8500.

The expression fn:round(3.1415e0, 2) returns 3.14e0.

fn:round-half-to-even($arg as numeric?) as numeric?
fn:round-half-to-even($arg as numeric?, $precision as xs:integer) as numeric?
Rounds a value to a specified number of decimal places, rounding to make the last digit even if two such values are equally near. See the XPath/XQuery function reference.
Examples:

The expression fn:round-half-to-even(0.5) returns 0.0.

The expression fn:round-half-to-even(1.5) returns 2.0.

The expression fn:round-half-to-even(2.5) returns 2.0.

The expression fn:round-half-to-even(3.567812e+3, 2) returns 3567.81e0.

The expression fn:round-half-to-even(4.7564e-3, 2) returns 0.0e0.

The expression fn:round-half-to-even(35612.25, -2) returns 35600.

fn:seconds-from-dateTime($arg as xs:dateTime?) as xs:decimal?
Returns the seconds component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:seconds-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00")) returns 0.

fn:seconds-from-duration($arg as xs:duration?) as xs:decimal?
Returns the number of seconds in a duration. See the XPath/XQuery function reference.
Examples:

The expression fn:seconds-from-duration(xs:dayTimeDuration("P3DT10H12.5S")) returns 12.5.

The expression fn:seconds-from-duration(xs:dayTimeDuration("-PT256S")) returns -16.0.

fn:seconds-from-time($arg as xs:time?) as xs:decimal?
Returns the seconds component of an xs:time. See the XPath/XQuery function reference.
Examples:

The expression fn:seconds-from-time(xs:time("13:20:10.5")) returns 10.5.

fn:serialize($arg as item()*) as xs:string(: XPath/XQuery 3.0 only :)
fn:serialize( $arg as item()*, $params as element(Q{http://www.w3.org/2010/xslt-xquery-serialization}serialization-parameters)?) as xs:string(: XPath/XQuery 3.0 only :)
This function serializes the supplied input sequence $arg as described in [XSLT and XQuery Serialization 3.0], returning the serialized representation of the sequence as a string. See the XPath/XQuery function reference.
Examples:

Given the output parameters:

let $params :=

<output:serialization-parameters xmlns:output="http://www.w3.org/2010/xslt-xquery-serialization">
  <output:omit-xml-declaration value="yes"/>
</output:serialization-parameters>
         

let $data :=

<a b='3'/>
         

The following call might produce the output shown:

The expression fn:serialize($data, $params) returns '<a b="3"/>'.

fn:starts-with($arg1 as xs:string?, $arg2 as xs:string?) as xs:boolean
fn:starts-with($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:boolean
Returns true if the string $arg1 contains $arg2 as a leading substring, taking collations into account. See the XPath/XQuery function reference.
Examples:

The collation used in these examples, http://example.com/CollationA is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [Unicode Collation Algorithm].

The expression fn:starts-with("tattoo", "tat") returns true().

The expression fn:starts-with ( "tattoo", "att") returns false().

The expression fn:starts-with ((), ()) returns true().

The expression fn:starts-with ( "abcdefghi", "-a-b-c-", "http://example.com/CollationA") returns true().

The expression fn:starts-with ( "a*b*c*d*e*f*g*h*i*", "a-bc-", "http://example.com/CollationA") returns true().

The expression fn:starts-with ( "abcd***e---f*--*ghi", "abcdef", "http://example.com/CollationA") returns true().

The expression fn:starts-with ( (), "--***-*---", "http://example.com/CollationA") returns true(). (The second argument contains only ignorable collation units and is equivalent to the zero-length string.).

The expression fn:starts-with ( "-abcdefghi", "-abc", "http://example.com/CollationA") returns true().

fn:static-base-uri( ) as xs:anyURI?
This function returns the value of the Static Base URI property from the static context. See the XPath/XQuery function reference.
fn:string( ) as xs:string
fn:string($arg as item()?) as xs:string
Returns the value of $arg represented as an xs:string. See the XPath/XQuery function reference.
Examples:

The expression string(23) returns "23".

The expression string(false()) returns "false".

The expression string("Paris") returns "Paris".

The expression string(abs#1) raises error FOTY0014.

let $para :=

<para>In a hole in the ground there lived a <term author="Tolkein">hobbit</term>.</para>
         

The expression string($para) returns "In a hole in the ground there lived a hobbit.".

fn:string-join($arg1 as xs:string*, $arg2 as xs:string) as xs:string
fn:string-join($arg1 as xs:string*) as xs:string(: XPath/XQuery 3.0 only :)
Returns a string created by concatenating the items in a sequence, with a defined separator between adjacent items. See the XPath/XQuery function reference.
Examples:

The expression fn:string-join(('Now', 'is', 'the', 'time', '...'), ' ') returns "Now is the time ...".

The expression fn:string-join(('Blow, ', 'blow, ', 'thou ', 'winter ', 'wind!'), '') returns "Blow, blow, thou winter wind!".

The expression fn:string-join((), 'separator') returns "".

Assume a document:

<doc>
  <chap>
    <section/>
  </chap>
</doc>

with the <section> element as the context node, the [XML Path Language (XPath) 2.0] expression:

fn:string-join(ancestor-or-self::*/name(), '/')

returns "doc/chap/section"

fn:string-length( ) as xs:integer
fn:string-length($arg as xs:string?) as xs:integer
Returns the number of ·characters· in a string. See the XPath/XQuery function reference.
Examples:

The expression fn:string-length("Harp not on that string, madam; that is past.") returns 45.

The expression fn:string-length(()) returns 0.

fn:string-to-codepoints($arg as xs:string?) as xs:integer*
Returns the sequence of ·codepoints· that constitute an xs:string value. See the XPath/XQuery function reference.
Examples:

The expression fn:string-to-codepoints("Thérèse") returns (84, 104, 233, 114, 232, 115, 101).

fn:subsequence($sourceSeq as item()*, $startingLoc as xs:double) as item()*
fn:subsequence($sourceSeq as item()*, $startingLoc as xs:double, $length as xs:double) as item()*
Returns the contiguous sequence of items in the value of $sourceSeq beginning at the position indicated by the value of $startingLoc and continuing for the number of items indicated by the value of $length. See the XPath/XQuery function reference.
Examples:

let $seq := ("item1", "item2", "item3", "item4", "item5")

The expression fn:subsequence($seq, 4) returns ("item4", "item5").

The expression fn:subsequence($seq, 3, 2) returns ("item3", "item4").

fn:substring($sourceString as xs:string?, $startingLoc as xs:double) as xs:string
fn:substring($sourceString as xs:string?, $startingLoc as xs:double, $length as xs:double) as xs:string
Returns the portion of the value of $sourceString beginning at the position indicated by the value of $start and continuing for the number of ·characters· indicated by the value of $length. See the XPath/XQuery function reference.
Examples:

The expression fn:substring("motor car", 6) returns " car". (Characters starting at position 6 to the end of $sourceString are selected.).

The expression fn:substring("metadata", 4, 3) returns "ada". (Characters at positions greater than or equal to 4 and less than 7 are selected.).

The expression fn:substring("12345", 1.5, 2.6) returns "234". (Characters at positions greater than or equal to 2 and less than 5 are selected.).

The expression fn:substring("12345", 0, 3) returns "12". (Characters at positions greater than or equal to 0 and less than 3 are selected. Since the first position is 1, these are the characters at positions 1 and 2.).

The expression fn:substring("12345", 5, -3) returns "". (Characters at positions greater than or equal to 5 and less than 2 are selected.).

The expression fn:substring("12345", -3, 5) returns "1". (Characters at positions greater than or equal to -3 and less than 2 are selected. Since the first position is 1, this is the character at position 1.).

The expression fn:substring("12345", 0 div 0E0, 3) returns "". (Since 0 div 0E0 returns NaN, and NaN compared to any other number returns false, no characters are selected.).

The expression fn:substring("12345", 1, 0 div 0E0) returns "". (As above.).

The expression fn:substring((), 1, 3) returns "".

The expression fn:substring("12345", -42, 1 div 0E0) returns "12345". (Characters at positions greater than or equal to -42 and less than INF are selected.).

The expression fn:substring("12345", -1 div 0E0, 1 div 0E0) returns "". (Since the value of -INF + INF is NaN, no characters are selected.).

fn:substring-after($arg1 as xs:string?, $arg2 as xs:string?) as xs:string
fn:substring-after($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string
Returns the part of $arg1 that follows the first occurrence of $arg2, taking collations into account. See the XPath/XQuery function reference.
Examples:

The collation used in these examples, http://example.com/CollationA is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [Unicode Collation Algorithm].

The expression fn:substring-after("tattoo", "tat") returns "too".

The expression fn:substring-after("tattoo", "tattoo") returns "".

The expression fn:substring-after((), ()) returns "".

The expression fn:substring-after("abcdefghi", "--d-e-", "http://example.com/CollationA") returns "fghi".

The expression fn:substring-after("abc--d-e-fghi", "--d-e-", "http://example.com/CollationA") returns "-fghi".

The expression fn:substring-after ( "a*b*c*d*e*f*g*h*i*", "***cde***", "http://example.com/CollationA") returns "*f*g*h*i*".

The expression fn:substring-after ( "Eureka!", "--***-*---", "http://example.com/CollationA") returns "Eureka!". (The second argument contains only ignorable collation units and is equivalent to the zero-length string.).

fn:substring-before($arg1 as xs:string?, $arg2 as xs:string?) as xs:string
fn:substring-before($arg1 as xs:string?, $arg2 as xs:string?, $collation as xs:string) as xs:string
Returns the part of $arg1 that precedes the first occurrence of $arg2, taking collations into account. See the XPath/XQuery function reference.
Examples:

The collation used in these examples, http://example.com/CollationA is a collation in which both "-" and "*" are ignorable collation units.

"Ignorable collation unit" is equivalent to "ignorable collation element" in [Unicode Collation Algorithm].

The expression fn:substring-before ( "tattoo", "attoo") returns "t".

The expression fn:substring-before ( "tattoo", "tatto") returns "".

The expression fn:substring-before ((), ()) returns "".

The expression fn:substring-before ( "abcdefghi", "--d-e-", "http://example.com/CollationA") returns "abc".

The expression fn:substring-before ( "abc--d-e-fghi", "--d-e-", "http://example.com/CollationA") returns "abc--".

The expression fn:substring-before ( "a*b*c*d*e*f*g*h*i*", "***cde", "http://example.com/CollationA") returns "a*b*".

The expression fn:substring-before ( "Eureka!", "--***-*---", "http://example.com/CollationA") returns "". (The second argument contains only ignorable collation units and is equivalent to the zero-length string.).

fn:sum($arg as xs:anyAtomicType*) as xs:anyAtomicType
fn:sum($arg as xs:anyAtomicType*, $zero as xs:anyAtomicType?) as xs:anyAtomicType?
Returns a value obtained by adding together the values in $arg. See the XPath/XQuery function reference.
Examples:

let $d1 := xs:yearMonthDuration("P20Y")

let $d2 := xs:yearMonthDuration("P10M")

let $seq1 := ($d1, $d2)

let $seq3 := (3, 4, 5)

The expression fn:sum(($d1, $d2)) returns xs:yearMonthDuration("P20Y10M").

The expression fn:sum($seq1[. lt xs:yearMonthDuration('P3M')], xs:yearMonthDuration('P0M')) returns xs:yearMonthDuration("P0M").

The expression fn:sum($seq3) returns 12.

The expression fn:sum(()) returns 0.

The expression fn:sum((),()) returns ().

The expression fn:sum((1 to 100)[. lt 0], 0) returns 0.

fn:sum(($d1, 9E1)) raises a type error [err:FORG0006].

The expression fn:sum(($d1, $d2), "ein Augenblick") returns xs:yearMonthDuration("P20Y10M"). (There is no requirement that the $zero value should be the same type as the items in $arg, or even that it should belong to a type that supports addition.).

fn:tail($arg as item()*) as item()*(: XPath/XQuery 3.0 only :)
Returns all but the first item in a sequence. See the XPath/XQuery function reference.
Examples:

The expression fn:tail(1 to 5) returns (2, 3, 4, 5).

The expression fn:tail(("a", "b", "c")) returns ("b", "c").

The expression fn:tail("a") returns ().

The expression fn:tail(()) returns ().

fn:timezone-from-date($arg as xs:date?) as xs:dayTimeDuration?
Returns the timezone component of an xs:date. See the XPath/XQuery function reference.
Examples:

The expression fn:timezone-from-date(xs:date("1999-05-31-05:00")) returns xs:dayTimeDuration("-PT5H").

The expression fn:timezone-from-date(xs:date("2000-06-12Z")) returns xs:dayTimeDuration("PT0S").

fn:timezone-from-dateTime($arg as xs:dateTime?) as xs:dayTimeDuration?
Returns the timezone component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:timezone-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00")) returns xs:dayTimeDuration("-PT5H").

The expression fn:timezone-from-dateTime(xs:dateTime("2000-06-12T13:20:00Z")) returns xs:dayTimeDuration("PT0S").

The expression fn:timezone-from-dateTime(xs:dateTime("2004-08-27T00:00:00")) returns ().

fn:timezone-from-time($arg as xs:time?) as xs:dayTimeDuration?
Returns the timezone component of an xs:time. See the XPath/XQuery function reference.
Examples:

The expression fn:timezone-from-time(xs:time("13:20:00-05:00")) returns xs:dayTimeDuration("-PT5H").

The expression fn:timezone-from-time(xs:time("13:20:00")) returns ().

fn:tokenize($input as xs:string?, $pattern as xs:string) as xs:string*
fn:tokenize($input as xs:string?, $pattern as xs:string, $flags as xs:string) as xs:string*
Returns a sequence of strings constructed by splitting the input wherever a separator is found; the separator is any substring that matches a given regular expression. See the XPath/XQuery function reference.
Examples:

The expression fn:tokenize("The cat sat on the mat", "\s+") returns ("The", "cat", "sat", "on", "the", "mat").

The expression fn:tokenize("1, 15, 24, 50", ",\s*") returns ("1", "15", "24", "50").

The expression fn:tokenize("1,15,,24,50,", ",") returns ("1", "15", "", "24", "50", "").

fn:tokenize("abba", ".?") raises the dynamic error [err:FORX0003].

The expression fn:tokenize("Some unparsed <br> HTML <BR> text", "\s*<br>\s*", "i") returns ("Some unparsed", "HTML", "text").

fn:trace($value as item()*, $label as xs:string) as item()*
Provides an execution trace intended to be used in debugging queries. See the XPath/XQuery function reference.
Examples:

Consider a situation in which a user wants to investigate the actual value passed to a function. Assume that in a particular execution, $v is an xs:decimal with value 124.84. Writing fn:trace($v, 'the value of $v is:') will put the strings "124.84" and "the value of $v is:" in the trace data set in implementation dependent order.

fn:translate($arg as xs:string?, $mapString as xs:string, $transString as xs:string) as xs:string
Returns the value of $arg modified by replacing or removing individual characters. See the XPath/XQuery function reference.
Examples:

The expression fn:translate("bar","abc","ABC") returns "BAr".

The expression fn:translate("--aaa--","abc-","ABC") returns "AAA".

The expression fn:translate("abcdabc", "abc", "AB") returns "ABdAB".

fn:true( ) as xs:boolean
Returns the xs:boolean value true. See the XPath/XQuery function reference.
Examples:

The expression fn:true() returns xs:boolean(1).

fn:unordered($sourceSeq as item()*) as item()
Returns the items of $sourceSeq in an ·implementation dependent· order. See the XPath/XQuery function reference.
Examples:

The expression fn:unordered((1, 2, 3, 4, 5)) returns some permutation of (1, 2, 3, 4, 5).

fn:unparsed-text($href as xs:string?) as xs:string?(: XPath/XQuery 3.0 only :)
fn:unparsed-text($href as xs:string?, $encoding as xs:string) as xs:string?(: XPath/XQuery 3.0 only :)
The fn:unparsed-text function reads an external resource (for example, a file) and returns a string representation of the resource. See the XPath/XQuery function reference.
Examples:

This XSLT example attempts to read a file containing 'boilerplate' HTML and copy it directly to the serialized output file:

<xsl:output method="html"/>

<xsl:template match="/">
  <xsl:value-of select="unparsed-text('header.html', 'iso-8859-1')"
                disable-output-escaping="yes"/>
  <xsl:apply-templates/>
  <xsl:value-of select="unparsed-text('footer.html', 'iso-8859-1')"
                disable-output-escaping="yes"/>
</xsl:template>
fn:unparsed-text-available($href as xs:string?) as xs:boolean(: XPath/XQuery 3.0 only :)
fn:unparsed-text-available($href as xs:string?, $encoding as xs:string) as xs:boolean(: XPath/XQuery 3.0 only :)
Because errors in evaluating the fn:unparsed-text function are non-recoverable, these two functions are provided to allow an application to determine whether a call with particular arguments would succeed. See the XPath/XQuery function reference.
fn:unparsed-text-lines($href as xs:string?) as xs:string*(: XPath/XQuery 3.0 only :)
fn:unparsed-text-lines($href as xs:string?, $encoding as xs:string) as xs:string*(: XPath/XQuery 3.0 only :)
The fn:unparsed-text-lines function reads an external resource (for example, a file) and returns its contents as a sequence of strings, one for each line of text in the string representation of the resource. See the XPath/XQuery function reference.
fn:upper-case($arg as xs:string?) as xs:string
Converts a string to upper case. See the XPath/XQuery function reference.
Examples:

The expression fn:upper-case("abCd0") returns "ABCD0".

fn:uri-collection( ) as xs:anyURI*(: XPath/XQuery 3.0 only :)
fn:uri-collection($arg as xs:string?) as xs:anyURI*(: XPath/XQuery 3.0 only :)
Returns a sequence of xs:anyURI values representing the URIs in a resource collection. See the XPath/XQuery function reference.
fn:year-from-date($arg as xs:date?) as xs:integer?
Returns the year component of an xs:date. See the XPath/XQuery function reference.
Examples:

The expression fn:year-from-date(xs:date("1999-05-31")) returns 1999.

The expression fn:year-from-date(xs:date("2000-01-01+05:00")) returns 2000.

fn:year-from-dateTime($arg as xs:dateTime?) as xs:integer?
Returns the year component of an xs:dateTime. See the XPath/XQuery function reference.
Examples:

The expression fn:year-from-dateTime(xs:dateTime("1999-05-31T13:20:00-05:00")) returns 1999.

The expression fn:year-from-dateTime(xs:dateTime("1999-05-31T21:30:00-05:00")) returns 1999.

The expression fn:year-from-dateTime(xs:dateTime("1999-12-31T19:20:00")) returns 1999.

The expression fn:year-from-dateTime(xs:dateTime("1999-12-31T24:00:00")) returns 2000.

fn:years-from-duration($arg as xs:duration?) as xs:integer?
Returns the number of years in a duration. See the XPath/XQuery function reference.
Examples:

The expression fn:years-from-duration(xs:yearMonthDuration("P20Y15M")) returns 21.

The expression fn:years-from-duration(xs:yearMonthDuration("-P15M")) returns -1.

The expression fn:years-from-duration(xs:dayTimeDuration("-P2DT15H")) returns 0.

fn:zero-or-one($arg as item()*) as item()?
Returns $arg if it contains zero or one items. Otherwise, raises an error. See the XPath/XQuery function reference.


Copyright  © 2014 W3C®(MIT, ERCIM,Keio, Beihang), This software or document includes material copied from or derived from XPath and XQuery Functions and Operators 3.0 (https://www.w3.org/TR/xpath-functions-30/).
This document is a non-normative summary of XPath/XQuery and documentation of its implementation, the reader is not allowed to use it as technical specification for anything.

Standard XPath/XQuery mathematical functions math:*

Namespace: http://www.w3.org/2005/xpath-functions/math
In the Pascal Internet Tools library the unit xquery_module_math.pas needs to be loaded, before these functions are available.math:acos($arg as xs:double?) as xs:double?
Returns the arc cosine of the argument, the result being in the range zero to +π radians. See the XPath/XQuery math function reference.
Examples:

The expression math:acos(()) returns ().

The expression math:acos(0) returns 1.5707963267948966e0 (approximately).

The expression math:acos(-0.0e0) returns 1.5707963267948966e0 (approximately).

The expression math:acos(1.0e0) returns 0.0e0.

The expression math:acos(-1.0e0) returns 3.141592653589793e0 (approximately).

The expression math:acos(2.0e0) returns xs:double('NaN').

The expression math:acos(xs:double('NaN')) returns xs:double('NaN').

The expression math:acos(xs:double('INF')) returns xs:double('NaN').

The expression math:acos(xs:double('-INF')) returns xs:double('NaN').

math:asin($arg as xs:double?) as xs:double?
Returns the arc sine of the argument, the result being in the range -π/2 to +π/2 radians. See the XPath/XQuery math function reference.
Examples:

The expression math:asin(()) returns ().

The expression math:asin(0) returns 0.0e0.

The expression math:asin(-0.0e0) returns -0.0e0.

The expression math:asin(1.0e0) returns 1.5707963267948966e0 (approximately).

The expression math:asin(-1.0e0) returns -1.5707963267948966e0 (approximately).

The expression math:asin(2.0e0) returns xs:double('NaN').

The expression math:asin(xs:double('NaN')) returns xs:double('NaN').

The expression math:asin(xs:double('INF')) returns xs:double('NaN').

The expression math:asin(xs:double('-INF')) returns xs:double('NaN').

math:atan($arg as xs:double?) as xs:double?
Returns the arc tangent of the argument, the result being in the range -π/2 to +π/2 radians. See the XPath/XQuery math function reference.
Examples:

The expression math:atan(()) returns ().

The expression math:atan(0) returns 0.0e0.

The expression math:atan(-0.0e0) returns -0.0e0.

The expression math:atan(1.0e0) returns 0.7853981633974483e0 (approximately).

The expression math:atan(-1.0e0) returns -0.7853981633974483e0 (approximately).

The expression math:atan(xs:double('NaN')) returns xs:double('NaN').

The expression math:atan(xs:double('INF')) returns 1.5707963267948966e0 (approximately).

The expression math:atan(xs:double('-INF')) returns -1.5707963267948966e0 (approximately).

math:atan2($y as xs:double, $x as xs:double) as xs:double
Returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis, the result being in the range -π to +π. See the XPath/XQuery math function reference.
Examples:

The expression math:atan2(+0.0e0, 0.0e0) returns 0.0e0.

The expression math:atan2(-0.0e0, 0.0e0) returns -0.0e0.

The expression math:atan2(+0.0e0, -0.0e0) returns math:pi().

The expression math:atan2(-0.0e0, -0.0e0) returns -math:pi().

The expression math:atan2(-1, 0.0e0) returns -math:pi() div 2.

The expression math:atan2(+1, 0.0e0) returns +math:pi() div 2.

The expression math:atan2(-0.0e0, -1) returns -math:pi().

The expression math:atan2(+0.0e0, -1) returns +math:pi().

The expression math:atan2(-0.0e0, +1) returns -0.0e0.

The expression math:atan2(+0.0e0, +1) returns +0.0e0.

math:cos( as xs:double?) as xs:double?
Returns the cosine of the argument, expressed in radians. See the XPath/XQuery math function reference.
Examples:

The expression math:cos(()) returns ().

The expression math:cos(0) returns 1.0e0.

The expression math:cos(-0.0e0) returns 1.0e0.

The expression math:cos(math:pi() div 2) returns 0.0e0 (approximately).

The expression math:cos(-math:pi() div 2) returns 0.0e0 (approximately).

The expression math:cos(math:pi()) returns -1.0e0.

The expression math:cos(xs:double('NaN')) returns xs:double('NaN').

The expression math:cos(xs:double('INF')) returns xs:double('NaN').

The expression math:cos(xs:double('-INF')) returns xs:double('NaN').

math:exp($arg as xs:double?) as xs:double?
Returns the value of ex. See the XPath/XQuery math function reference.
Examples:

The expression math:exp(()) returns ().

The expression math:exp(0) returns 1.0e0.

The expression math:exp(1) returns 2.7182818284590455e0.

The expression math:exp(2) returns 7.38905609893065e0.

The expression math:exp(-1) returns 0.36787944117144233e0.

The expression math:exp(math:pi()) returns 23.140692632779267e0.

The expression math:exp(xs:double('NaN')) returns xs:double('NaN').

The expression math:exp(xs:double('INF')) returns xs:double('INF').

The expression math:exp(xs:double('-INF')) returns 0.0e0.

math:exp10($arg as xs:double?) as xs:double?
Returns the value of 10x. See the XPath/XQuery math function reference.
Examples:

The expression math:exp10(()) returns ().

The expression math:exp10(0) returns 1.0e0.

The expression math:exp10(1) returns 1.0e1.

The expression math:exp10(0.5) returns 3.1622776601683795e0.

The expression math:exp10(-1) returns 1.0e-1.

The expression math:exp10(xs:double('NaN')) returns xs:double('NaN').

The expression math:exp10(xs:double('INF')) returns xs:double('INF').

The expression math:exp10(xs:double('-INF')) returns 0.0e0.

math:log($arg as xs:double?) as xs:double?
Returns the natural logarithm of the argument. See the XPath/XQuery math function reference.
Examples:

The expression math:log(()) returns ().

The expression math:log(0) returns xs:double('-INF').

The expression math:log(math:exp(1)) returns 1.0e0.

The expression math:log(1.0e-3) returns -6.907755278982137e0.

The expression math:log(2) returns 0.6931471805599453e0.

The expression math:log(-1) returns xs:double('NaN').

The expression math:log(xs:double('NaN')) returns xs:double('NaN').

The expression math:log(xs:double('INF')) returns xs:double('INF').

The expression math:log(xs:double('-INF')) returns xs:double('NaN').

math:log10($arg as xs:double?) as xs:double?
Returns the base-ten logarithm of the argument. See the XPath/XQuery math function reference.
Examples:

The expression math:log10(()) returns ().

The expression math:log10(0) returns xs:double('-INF').

The expression math:log10(1.0e3) returns 3.0e0.

The expression math:log10(1.0e-3) returns -3.0e0.

The expression math:log10(2) returns 0.3010299956639812e0.

The expression math:log10(-1) returns xs:double('NaN').

The expression math:log10(xs:double('NaN')) returns xs:double('NaN').

The expression math:log10(xs:double('INF')) returns xs:double('INF').

The expression math:log10(xs:double('-INF')) returns xs:double('NaN').

math:pi( ) as xs:double
Returns an approximation to the mathematical constant π. See the XPath/XQuery math function reference.
Examples:

The expression 2*math:pi() returns 6.283185307179586e0.

The expression 60 * (math:pi() div 180) converts an angle of 60 degrees to radians.

math:pow($x as xs:double?, $y as numeric) as xs:double?
Returns the result of raising the first argument to the power of the second. See the XPath/XQuery math function reference.
Examples:

The expression math:pow((), 93.7) returns ().

The expression math:pow(2, 3) returns 8.0e0.

The expression math:pow(-2, 3) returns -8.0e0.

The expression math:pow(2, -3) returns 0.125e0.

The expression math:pow(-2, -3) returns -0.125e0.

The expression math:pow(2, 0) returns 1.0e0.

The expression math:pow(0, 0) returns 1.0e0.

The expression math:pow(xs:double('INF'), 0) returns 1.0e0.

The expression math:pow(xs:double('NaN'), 0) returns 1.0e0.

The expression math:pow(-math:pi(), 0) returns 1.0e0.

The expression math:pow(0e0, 3) returns 0.0e0.

The expression math:pow(0e0, 4) returns 0.0e0.

The expression math:pow(-0e0, 3) returns -0.0e0.

The expression math:pow(0, 4) returns 0.0e0.

The expression math:pow(0e0, -3) returns xs:double('INF').

The expression math:pow(0e0, -4) returns xs:double('INF').

The expression math:pow(-0e0, -3) returns xs:double('-INF').

The expression math:pow(0, -4) returns xs:double('INF').

The expression math:pow(16, 0.5e0) returns 4.0e0.

The expression math:pow(16, 0.25e0) returns 2.0e0.

The expression math:pow(0e0, -3.0e0) returns xs:double('INF').

The expression math:pow(-0e0, -3.0e0) returns xs:double('-INF'). (Odd-valued whole numbers are treated specially).

The expression math:pow(0e0, -3.1e0) returns xs:double('INF').

The expression math:pow(-0e0, -3.1e0) returns xs:double('INF').

The expression math:pow(0e0, 3.0e0) returns 0.0e0.

The expression math:pow(-0e0, 3.0e0) returns -0.0e0. (Odd-valued whole numbers are treated specially).

The expression math:pow(0e0, 3.1e0) returns 0.0e0.

The expression math:pow(-0e0, 3.1e0) returns 0.0e0.

The expression math:pow(-1, xs:double('INF')) returns 1.0e0.

The expression math:pow(-1, xs:double('-INF')) returns 1.0e0.

The expression math:pow(1, xs:double('INF')) returns 1.0e0.

The expression math:pow(1, xs:double('-INF')) returns 1.0e0.

The expression math:pow(1, xs:double('NaN')) returns 1.0e0.

The expression math:pow(-2.5e0, 2.0e0) returns 6.25e0.

The expression math:pow(-2.5e0, 2.00000001e0) returns xs:double('NaN').

math:sin( as xs:double?) as xs:double?
Returns the sine of the argument, expressed in radians. See the XPath/XQuery math function reference.
Examples:

The expression math:sin(()) returns ().

The expression math:sin(0) returns 0.0e0.

The expression math:sin(-0.0e0) returns -0.0e0.

The expression math:sin(math:pi() div 2) returns 1.0e0.

The expression math:sin(-math:pi() div 2) returns -1.0e0.

The expression math:sin(math:pi()) returns 0.0e0 (approximately).

The expression math:sin(xs:double('NaN')) returns xs:double('NaN').

The expression math:sin(xs:double('INF')) returns xs:double('NaN').

The expression math:sin(xs:double('-INF')) returns xs:double('NaN').

math:sqrt($arg as xs:double?) as xs:double?
Returns the non-negative square root of the argument. See the XPath/XQuery math function reference.
Examples:

The expression math:sqrt(()) returns ().

The expression math:sqrt(0.0e0) returns 0.0e0.

The expression math:sqrt(-0.0e0) returns -0.0e0.

The expression math:sqrt(1.0e6) returns 1.0e3.

The expression math:sqrt(2.0e0) returns 1.4142135623730951e0.

The expression math:sqrt(-2.0e0) returns xs:double('NaN').

The expression math:sqrt(xs:double('NaN')) returns xs:double('NaN').

The expression math:sqrt(xs:double('INF')) returns xs:double('INF').

The expression math:sqrt(xs:double('-INF')) returns xs:double('NaN').

math:tan( as xs:double?) as xs:double?
Returns the tangent of the argument, expressed in radians. See the XPath/XQuery math function reference.
Examples:

The expression math:tan(()) returns ().

The expression math:tan(0) returns 0.0e0.

The expression math:tan(-0.0e0) returns -0.0e0.

The expression math:tan(math:pi() div 4) returns 1.0e0 (approximately).

The expression math:tan(-math:pi() div 4) returns -1.0e0 (approximately).

The expression math:tan(math:pi() div 2) returns 1.633123935319537E16 (approximately).

The expression math:tan(-math:pi() div 2) returns -1.633123935319537E16 (approximately).

The expression math:tan(math:pi()) returns 0.0e0 (approximately).

The expression math:tan(xs:double('NaN')) returns xs:double('NaN').

The expression math:tan(xs:double('INF')) returns xs:double('NaN').

The expression math:tan(xs:double('-INF')) returns xs:double('NaN').



Copyright  © 2014 W3C®(MIT, ERCIM,Keio, Beihang), This software or document includes material copied from or derived from XPath and XQuery Functions and Operators 3.0 (https://www.w3.org/TR/xpath-functions-30/).
This document is a non-normative summary of XPath/XQuery and documentation of its implementation, the reader is not allowed to use it as technical specification for anything.

Standard type constructors xs:*

Namespace: http://www.w3.org/2001/XMLSchema
Prefix xs can be omitted.xs:anyURI($arg as xs:anyAtomicType?) as xs:anyURI?

Casts a value to the XML Schema type anyURI.

xs:base64Binary($arg as xs:anyAtomicType?) as xs:base64Binary?

Casts a value to the XML Schema type base64Binary.

xs:boolean($arg as xs:anyAtomicType?) as xs:boolean?

Casts a value to the XML Schema type boolean.

xs:byte($arg as xs:anyAtomicType?) as xs:byte?

Casts a value to the XML Schema type byte.

xs:date($arg as xs:anyAtomicType?) as xs:date?

Casts a value to the XML Schema type date.

xs:dateTime($arg as xs:anyAtomicType?) as xs:dateTime?

Casts a value to the XML Schema type dateTime.

xs:dateTimeStamp($arg as xs:anyAtomicType?) as xs:dateTimeStamp?(: XPath/XQuery 3.0 only :)

Casts a value to the XML Schema type dateTimeStamp.

xs:dayTimeDuration($arg as xs:anyAtomicType?) as xs:dayTimeDuration?

Casts a value to the XML Schema type dayTimeDuration.

xs:decimal($arg as xs:anyAtomicType?) as xs:decimal?

Casts a value to the XML Schema type decimal.

xs:double($arg as xs:anyAtomicType?) as xs:double?

Casts a value to the XML Schema type double.

xs:duration($arg as xs:anyAtomicType?) as xs:duration?

Casts a value to the XML Schema type duration.

xs:ENTITIES($arg as xs:anyAtomicType?) as xs:ENTITIES?

Casts a value to the XML Schema type ENTITIES.

xs:ENTITY($arg as xs:anyAtomicType?) as xs:ENTITY?

Casts a value to the XML Schema type ENTITY.

xs:error($arg as xs:anyAtomicType?) as xs:error?(: XPath/XQuery 3.0 only :)

Casts a value to the XML Schema type error.

xs:float($arg as xs:anyAtomicType?) as xs:float?

Casts a value to the XML Schema type float.

xs:gDay($arg as xs:anyAtomicType?) as xs:gDay?

Casts a value to the XML Schema type gDay.

xs:gMonth($arg as xs:anyAtomicType?) as xs:gMonth?

Casts a value to the XML Schema type gMonth.

xs:gMonthDay($arg as xs:anyAtomicType?) as xs:gMonthDay?

Casts a value to the XML Schema type gMonthDay.

xs:gYear($arg as xs:anyAtomicType?) as xs:gYear?

Casts a value to the XML Schema type gYear.

xs:gYearMonth($arg as xs:anyAtomicType?) as xs:gYearMonth?

Casts a value to the XML Schema type gYearMonth.

xs:hexBinary($arg as xs:anyAtomicType?) as xs:hexBinary?

Casts a value to the XML Schema type hexBinary.

xs:ID($arg as xs:anyAtomicType?) as xs:ID?

Casts a value to the XML Schema type ID.

xs:IDREF($arg as xs:anyAtomicType?) as xs:IDREF?

Casts a value to the XML Schema type IDREF.

xs:IDREFS($arg as xs:anyAtomicType?) as xs:IDREFS?

Casts a value to the XML Schema type IDREFS.

xs:int($arg as xs:anyAtomicType?) as xs:int?

Casts a value to the XML Schema type int.

xs:integer($arg as xs:anyAtomicType?) as xs:integer?

Casts a value to the XML Schema type integer.

xs:language($arg as xs:anyAtomicType?) as xs:language?

Casts a value to the XML Schema type language.

xs:long($arg as xs:anyAtomicType?) as xs:long?

Casts a value to the XML Schema type long.

xs:Name($arg as xs:anyAtomicType?) as xs:Name?

Casts a value to the XML Schema type Name.

xs:NCName($arg as xs:anyAtomicType?) as xs:NCName?

Casts a value to the XML Schema type NCName.

xs:negativeInteger($arg as xs:anyAtomicType?) as xs:negativeInteger?

Casts a value to the XML Schema type negativeInteger.

xs:NMTOKEN($arg as xs:anyAtomicType?) as xs:NMTOKEN?

Casts a value to the XML Schema type NMTOKEN.

xs:NMTOKENS($arg as xs:anyAtomicType?) as xs:NMTOKENS?

Casts a value to the XML Schema type NMTOKENS.

xs:nonNegativeInteger($arg as xs:anyAtomicType?) as xs:nonNegativeInteger?

Casts a value to the XML Schema type nonNegativeInteger.

xs:nonPositiveInteger($arg as xs:anyAtomicType?) as xs:nonPositiveInteger?

Casts a value to the XML Schema type nonPositiveInteger.

xs:normalizedString($arg as xs:anyAtomicType?) as xs:normalizedString?

Casts a value to the XML Schema type normalizedString.

xs:positiveInteger($arg as xs:anyAtomicType?) as xs:positiveInteger?

Casts a value to the XML Schema type positiveInteger.

xs:QName($arg as xs:anyAtomicType?) as xs:QName?

Casts a value to the XML Schema type QName.

xs:short($arg as xs:anyAtomicType?) as xs:short?

Casts a value to the XML Schema type short.

xs:string($arg as xs:anyAtomicType?) as xs:string?

Casts a value to the XML Schema type string.

xs:time($arg as xs:anyAtomicType?) as xs:time?

Casts a value to the XML Schema type time.

xs:token($arg as xs:anyAtomicType?) as xs:token?

Casts a value to the XML Schema type token.

xs:unsignedByte($arg as xs:anyAtomicType?) as xs:unsignedByte?

Casts a value to the XML Schema type unsignedByte.

xs:unsignedInt($arg as xs:anyAtomicType?) as xs:unsignedInt?

Casts a value to the XML Schema type unsignedInt.

xs:unsignedLong($arg as xs:anyAtomicType?) as xs:unsignedLong?

Casts a value to the XML Schema type unsignedLong.

xs:unsignedShort($arg as xs:anyAtomicType?) as xs:unsignedShort?

Casts a value to the XML Schema type unsignedShort.

xs:untypedAtomic($arg as xs:anyAtomicType?) as xs:untypedAtomic?

Casts a value to the XML Schema type untypedAtomic.

xs:yearMonthDuration($arg as xs:anyAtomicType?) as xs:yearMonthDuration?

Casts a value to the XML Schema type yearMonthDuration.

JSONiq base functions jn:*

Namespace: http://jsoniq.org/functions
In the Pascal Internet Tools library the unit xquery_json.pas needs to be loaded, before these functions are available.jn:is-null($arg as item()) as xs:boolean
Function was removed from JSONiq as it is redundant with eq and instance of operators.

See JSONiq reference.

jn:json-doc($uri as xs:string?) as json-item()?

This function returns the JSON node associated with the supplied URI. It has the same semantics as fn:doc, except that it returns an Object or an Array. See JSONiq reference.

jn:keys($arg as item()*) as xs:string*

This function returns all keys of all objects in the supplied sequence, using the jdm:keys accessor, with duplicates eliminated. The order in which the keys are returned is implementation-dependent but must be stable within a snapshot. Non-objects in the input sequence are ignored. See JSONiq reference.

jn:members($arg as item()*) as item()*

This functions returns all values that are in all arrays of an input sequence, preserving the order. Non-arrays in the input sequence are ignored. See JSONiq reference.

jn:null( ) as xs:null

This function returns the JSON null. See JSONiq reference.

jn:object(0 to unlimited arguments)
Function was removed from JSONiq as it is redundant with {||} syntax.

See JSONiq reference.

jn:parse-json($arg as xs:string?) as json-item()*
jn:parse-json($arg as xs:string?, $options as object()) as json-item()*

This function has the same semantics as fn:parse-xml(), except that it parses the string as JSON (not XML), and returns a sequence of objects or arrays rather than an XML document. See JSONiq reference.

jn:size($arg as array()?) as xs:integer?

This function returns the size of the supplied array using the jdm:size accessor (or the empty sequence if the empty sequence is provided). See JSONiq reference.

The JSONiq sections are taken from the JSONiq reference and are again licensed as CC-BY-SA.

JSONiq library functions jnlib:*

Namespace: http://jsoniq.org/function-library
In the Pascal Internet Tools library the unit xquery_json.pas needs to be loaded, before these functions are available.jnlib:accumulate($seq as item()*) as object()

This function dynamically builds an object, like jn:object, except that it does not throw an error upon pair collision. Instead, it accumulates them into an array. Non-object items in the input sequence are ignored. See JSONiq reference.

jnlib:descendant-arrays($seq as item()*) as array()*

This function returns all arrays contained within the supplied items, regardless of depth. See JSONiq reference.

jnlib:descendant-objects($seq as item()*) as object()*

This function returns all objects contained within the supplied items, regardless of depth. See JSONiq reference.

jnlib:descendant-pairs($seq as item()*) as item()*

This function returns all descendant pairs within the supplied items. See JSONiq reference.

jnlib:flatten($seq as item()*) as item()*

This function recursively "flattens" the supplied (top-level) arrays, leaving non-arrays unchanged. See JSONiq reference.

jnlib:intersect($seq as item()*) as object()

This function returns an object that only contains keys shared by all input objects, and associates to each of these keys the corresponding values in the input objects (wrapped in an array if more than one). Non-objects are ignored. See JSONiq reference.

jnlib:project($seq as item()*, $keys as xs:string*) as item()*

This function iterates on the input sequence. It projects objects by filtering their pairs and leaves non-objects intact. See JSONiq reference.

jnlib:remove-keys($seq as item()*, $keys as xs:string*) as item()*

This function iterates on the input sequence. It removes the pairs with the given keys from all objects and leaves non-objects intact. See JSONiq reference.

jnlib:values($seq as item()*) as item()*

This function returns all values in the supplied objects. Non-objects are ignored. See JSONiq reference.

The JSONiq sections are taken from the JSONiq reference and are again licensed as CC-BY-SA.

EXPath Module File file:*

Namespace: http://expath.org/ns/file
In the Pascal Internet Tools library the unit xquery_module_file.pas needs to be loaded, before these functions are available.file:append($file as xs:string, $items as item()*) as empty-sequence()
file:append($file as xs:string, $items as item()*, $params as element(output:serialization-parameters)) as empty-sequence()

Appends a sequence of items to a file. If the file pointed by $file does not exist, a new file will be created. See EXPath file specification.

file:append-binary($file as xs:string, $value as xs:base64Binary) as empty-sequence()

Appends a Base64 item as binary to a file. If the file pointed by $file does not exist, a new file will be created. See EXPath file specification.

file:append-text($file as xs:string, $value as xs:string) as empty-sequence()
file:append-text($file as xs:string, $value as xs:string, $encoding as xs:string) as empty-sequence()

Appends a string to a file. If the file pointed by $file does not exist, a new file will be created. See EXPath file specification.

file:append-text-lines($file as xs:string, $values as xs:string*) as empty-sequence()
file:append-text-lines($file as xs:string, $lines as xs:string*, $encoding as xs:string) as empty-sequence()

Appends a sequence of strings to a file, each followed by the system-dependent newline character. If the file pointed by $file does not exist, a new file will be created. See EXPath file specification.

file:base-dir( ) as xs:string

Returns the parent directory of the static base URI. If the Base URI property is undefined, the empty sequence is returned. - If a static base URI exists, and if points to a local file path, this function returns the same result as the expression file:parent(static-base-uri()). See EXPath file specification.

file:children($path as xs:string) as xs:string*

Returns the paths of all files and directories that are located in the given directory. The order of the items in the resulting sequence is not defined. The "." and ".." items are never returned. See EXPath file specification.

file:copy($source as xs:string, $target as xs:string) as empty-sequence()

Copies a file or a directory given a source and a target path/URI. The following cases may occur if $source points to a file: See EXPath file specification.

file:create-dir($dir as xs:string) as empty-sequence()

Creates a directory, or does nothing if the directory already exists. The operation will create all non-existing parent directories. See EXPath file specification.

file:create-temp-dir($prefix as xs:string, $suffix as xs:string) as xs:string
file:create-temp-dir($prefix as xs:string, $suffix as xs:string, $dir as xs:string) as xs:string

Creates a temporary directory and all non-existing parent directories and returns the full path to the created directory. See EXPath file specification.

file:create-temp-file($prefix as xs:string, $suffix as xs:string) as xs:string
file:create-temp-file($prefix as xs:string, $suffix as xs:string, $dir as xs:string) as xs:string

Creates a temporary file and all non-existing parent directories and returns the full path to the created file. See EXPath file specification.

file:current-dir( ) as xs:string

Returns the current working directory. - This function returns the same result as the function call file:resolve-path('.'). See EXPath file specification.

file:delete($path as xs:string) as empty-sequence()
file:delete($path as xs:string, $recursive as xs:boolean) as empty-sequence()

Deletes a file or a directory from the file system. See EXPath file specification.

file:dir-separator( ) as xs:string

Returns the value of the operating system-specific directory separator, which usually is / on UNIX-based systems and \ on Windows systems. See EXPath file specification.

file:exists($path as xs:string) as xs:boolean

Tests if the file or directory pointed by $path exists. See EXPath file specification.

file:is-dir($path as xs:string) as xs:boolean

Tests if $path points to a directory. On UNIX-based systems the root and the volume roots are considered directories. See EXPath file specification.

file:is-file($path as xs:string) as xs:boolean

Tests if $path points to a file. See EXPath file specification.

file:last-modified($path as xs:string) as xs:dateTime

Returns the last modification time of a file or directory. See EXPath file specification.

file:line-separator( ) as xs:string

Returns the value of the operating system-specific line separator, which usually is &#10; on UNIX-based systems, &#13;&#10; on Windows systems and &#13; on Mac systems. See EXPath file specification.

file:list($dir as xs:string) as xs:string*
file:list($dir as xs:string, $recursive as xs:boolean) as xs:string*
file:list($dir as xs:string, $recursive as xs:boolean, $pattern as xs:string) as xs:string*

Lists all files and directories in a given directory. The order of the items in the resulting sequence is not defined. The "." and ".." items are never returned. The returned paths are relative to the provided directory $dir. See EXPath file specification.

file:move($source as xs:string, $target as xs:string) as empty-sequence()

Moves a file or a directory given a source and a target path/URI. The following cases may occur if $source points to a file: See EXPath file specification.

file:name($path as xs:string) as xs:string

Returns the name of a file or directory. See EXPath file specification.

file:parent($path as xs:string) as xs:string?

Transforms the given path into an absolute path, as specified by file:resolve-path, and returns the parent directory. See EXPath file specification.

file:path-separator( ) as xs:string

Returns the value of the operating system-specific path separator, which usually is : on UNIX-based systems and ; on Windows systems. See EXPath file specification.

file:path-to-native($path as xs:string) as xs:string

Transforms a URI, an absolute path, or relative path to a canonical, system-dependent path representation. A canonical path is both absolute and unique and thus contains no redirections such as references to parent directories or symbolic links. See EXPath file specification.

file:path-to-uri($path as xs:string) as xs:anyURI

Transforms a file system path into a URI with the file:// scheme. If the path is relative, it is first resolved against the current working directory. See EXPath file specification.

file:read-binary($file as xs:string) as xs:base64Binary
file:read-binary($file as xs:string, $offset as xs:integer) as xs:base64Binary
file:read-binary($file as xs:string, $offset as xs:integer, $length as xs:integer) as xs:base64Binary

Returns the content of a file in its Base64 representation. See EXPath file specification.

file:read-text($file as xs:string) as xs:string
file:read-text($file as xs:string, $encoding as xs:string) as xs:string

Returns the content of a file in its string representation. See EXPath file specification.

file:read-text-lines($file as xs:string) as xs:string*
file:read-text-lines($file as xs:string, $encoding as xs:string) as xs:string*

Returns the contents of a file as a sequence of strings, separated at newline boundaries. See EXPath file specification.

file:resolve-path($path as xs:string) as xs:string

Transforms a relative path into an absolute operating system path by resolving it against the current working directory. See EXPath file specification.

file:size($file as xs:string) as xs:integer

Returns the byte size of a file, or the value 0 for directories. See EXPath file specification.

file:temp-dir( ) as xs:string

Returns the path to the default temporary-file directory of an operating system. See EXPath file specification.

file:write($file as xs:string, $items as item()*) as empty-sequence()
file:write($file as xs:string, $items as item()*, $params as element(Q{http://www.w3.org/2010/xslt-xquery-serialization}serialization-parameters)) as empty-sequence()

Writes a sequence of items to a file. If $file already exists, it will be overwritten; otherwise, it will be created. See EXPath file specification.

file:write-binary($file as xs:string, $value as xs:base64Binary) as empty-sequence()
file:write-binary($file as xs:string, $value as xs:base64Binary, $offset as xs:integer) as empty-sequence()

Writes a Base64 item as binary to a file. If $file already exists, it will be overwritten; otherwise, it will be created. See EXPath file specification.

file:write-text($file as xs:string, $value as xs:string) as empty-sequence()
file:write-text($file as xs:string, $value as xs:string, $encoding as xs:string) as empty-sequence()

Writes a strings to a file. If $file already exists, it will be overwritten. See EXPath file specification.

file:write-text-lines($file as xs:string, $values as xs:string*) as empty-sequence()
file:write-text-lines($file as xs:string, $values as xs:string*, $encoding as xs:string) as empty-sequence()

Writes a sequence of strings to a file, each followed by the system-dependent newline character. If $file already exists, it will be overwritten; otherwise, it will be created. See EXPath file specification.

Extension functions (primary) pxp:*, x:*

Namespace: .benibela.de
Identical copies of these functions are available in namespace x:* and namespace pxp:*.
Prefix pxp can be omitted.x:binary-to-string($data as xs:hexBinary|xs:base64Binary) as xs:string
x:binary-to-string($data as xs:hexBinary|xs:base64Binary, $encoding as xs:string) as xs:string
Converts $data to a string using the given $encoding
x:css(1 argument)
x:css($css as xs:string)
This returns the nodes below the context node matched by the specified CSS 3 selector.
You can use this to combine CSS and XPath, like in css("a.aclass")/@href.
x:deep-text(0 to 1 arguments)
This is the concatenated plain text of the every tag inside the current text.
You can also pass a separator like deep-text(' ') to separate text of different nodes.
x:eval(1 to 2 arguments)
x:eval($query as xs:string)
This will evaluate a string as an XPath/XQuery expression
x:extract(2 to 4 arguments)
x:extract($string as xs:string, $regex as xs:string [ , $match as xs:integer * , [$flags as xs:string] ] )
This applies the regex $regex to $string and returns only the matching part. This returns basically what the program grep would return.
If the $match argument is provided, only the $match-th submatch will be returned. This can be a sequence of several integers.
If flags contains *, all occurrences are returned.
Otherwise the regex and flags parameters behave identical to the parameters of fn:matches and fn:replace.
x:form(1 to 2 arguments)
x:form($form as node()*[ , $override as item()*] )
This creates the request corresponding to a HTML form. The request includes the value of all input/select/textarea descendants of the first parameter.
You can use the second parameter to give a sequence of values replacing the default values of the form elements.
A value is either a string, e.g. "name=value&name2=..." which has to be url encoded and is splitted at the &-separators by this function to override each parameter separately. (so the order of the name=value pairs is changed to the order of the input elements in the form). For example form(//form[1], "foo=bar&xyz=123") returns a request for the first form, with the foo and xyz input fields overridden by bar and 123.
Or a JSON-like object {"name": "value", ...}, in which the properties must not be url encodeded (i.e. the form method url encodes each property) and in which each property overrides the corresponding input field. For example form(//form[1], {"foo": "bar", "xyz": 123})

It returns a JSON object with these properties:
Depending on the enctype attribute of the HTML form, this function will either return url encoded or multipart encoded post data.
For latter, also a Content-Type header with the specific boundary is added.
For multipart encoded data, the value parameters do not have to be strings, but can be JSON-objects. They can have these properties:
x:form-combine($uri1 as object(), $uri2 as item()*) as object()
x:garbage-collect(0 arguments)
Frees unused memory. Always call it as garbage-collect()[0], or it might garbage collect its own return value and crash.
x:get($name as xs:string) as item()*
x:get($name as xs:string, $def as item()*) as item()*
Returns the value of a global variable.
x:get-property(2 arguments)
Returns the property with the given name of an object.
Deprecated, now the JSONiq syntax $obj($name) should be used.
x:inner-html(0 to 1 arguments)
This is the HTML content of a node, like innerHTML in javascript.
x:inner-xml(0 to 1 arguments)
This is the XML content of a node, similar to x:inner-html() or innerHTML in JavaScript
x:is-nth(3 arguments)
x:is-nth($i as xs:integer, $a as xs:integer, $b as xs:integer)
Returns true iff the equation i = a * n + b can be solved by an non-negative integer n. (This is used to implement the CSS functions like nth-child )
x:join(1 to 2 arguments)
x:join($sequence, [$separator])
This is basically the same as string-join, but can be used for non-string values. E.g. join((1,2,3)) returns the string "1 2 3".
x:object(0 to 1 arguments)
This creates an object with name $var. Default values can be passed as sequence of name/value pairs.
A alternative syntax is {}
x:outer-html(0 to 1 arguments)
This is the same as inner-html, but includes the opening/closing tags of the node itself
x:outer-xml(0 to 1 arguments)
Like outer-html(), but XML-serialized
x:parse-date(2 arguments)
x:parse-date($input as xs:string, $format as xs:string) as xs:date
Reads a date/time from string with the given format. The 2nd parameter $format is a standard Pascal format. (see x:parse-dateTime)
x:parse-dateTime(2 arguments)
x:parse-dateTime($input as xs:string, $format as xs:string) as xs:dateTime
Reads a date/time from string with the given format. The 2nd parameter $format is a standard Pascal format, using ymdhnsz (e.g. "yyyy-mm-dd"), not a XQuery 3.0 picture string.
x:parse-html($arg as xs:string?) as document-node(element(*)) ?
Parses an HTML document similar to fn:parse-xml. If the string is invalid HTML, it might be partially repaired by inserted missing tags.
x:parse-time(2 arguments)
x:parse-time($input as xs:string, $format as xs:string) as xs:time
Reads a date/time from string with the given format. The 2nd parameter $format is a standard Pascal format (see x:parse-dateTime)
x:random(0 to 1 arguments)
Returns a random number
x:random-seed(0 to 1 arguments)
Initializes the random number generator
x:request-combine($uri1 as object(), $uri2 as item()*) as object()
This function can be used to modify the object returned by x:form. (preliminary) The second parameter behaves like that parameter of x:form.
x:resolve-html(1 to 2 arguments)
Resolves every value in the $relative sequence to an HTTP request with an absolute URL/URI, using $base as reference base URI.
Atomic values (e.g. strings) are resolved as simple URIs similar to fn:resolve-uri.
For HTML elements that refer to other resources (e.g. <a href=...> or <img src=...>) it returns the absolute URI of that resource. For <form> elements it returns the same object as the form function. For all other HTML elements it interprets the text content as relative string URI.
If $base is not a node it treated as simple absolute URI. If $base is a node, the function uses the base URI of the document that contains the node.
x:sleep(1 argument)
Sleeps for a certain amount of milliseconds.
x:split-equal(2 to 3 arguments)
Compares strings like the @class attribute.
x:string-to-base64Binary($data as xs:string) as xs:base64Binary
x:string-to-base64Binary($data as xs:string, $encoding as xs:string) as xs:base64Binary
Returns a base64 binary representation of $data with the given $encoding
x:string-to-hexBinary($data as xs:string) as xs:hexBinary
x:string-to-hexBinary($data as xs:string, $encoding as xs:string) as xs:hexBinary
Returns a hex binary representation of $data with the given $encoding
x:transform($root as item()*, $f as function(*), $options as object()) as item()*
x:transform($root as item()*, $f as function(*)) as item()*
x:transform($f as function(*)) as item()*
This function can perform an arbitrary transformation of a document, by calling the transformer-function $f for every descendant node and replacing the node with the value returned by the function.
For example transform(/, function($x) { if (name($x) = "a") then <a>{$x/@*, <b>{$x/node()}</b>}</a> else $x } ) will make every link bold.
If $root is omitted, the context item . is used.
If $options("always-recurse") is true, all values returned by $f are also transformed with further calls of $f.
Preliminary, behavior might change in future versions. E.g. it might be renamed to map-nodes


x:type-of(1 argument)
Debugging function
x:uri-combine($uri1 as item()*, $uri2 as item()*) as xs:string
x:uri-decode($uri-part as xs:string?) as xs:string
x:uri-decode($uri-part as xs:string?)
Decodes an URI string. The reverse of uri-encode (but no roundtrip guarantee)
x:uri-encode($uri-part as xs:string?) as xs:string
x:uri-encode($uri-part as xs:string?)
Encodes a string for a URI. Exactly the same as fn:encode-for-uri but with a simpler name.

Extension functions in old namespace pxp:*

Namespace: http://www.benibela.de/2012/pxp/extensions
Prefix pxp can be omitted.pxp:json($arg as xs:string) as item()*
pxp:json($arg as xs:string, $options as object()) as item()*
Parses a string as JSON.
If the string is an url the JSON is loaded from there (i.e. be aware of possible security issues when using it. jn:parse-json from xquery_json / JSONiq will only parse it and fail on urls)
(available in Xidel and the xquery_json unit)
pxp:match(2 arguments)
pxp:match($pattern as item(), $node as node()+)
Performs pattern matching between the pattern $pattern (see pattern/template documentation) and the nodes, and returns a list or an object of matched values.
For example match(<a>{{.}}</a>, <x><a>FOO</a><a>BAR</a></x>) returns <a>FOO</a>, and match(<a>*{{.}}</a>, <x><a>FOO</a><a>BAR</a></x>) returns (<a>FOO</a>, <a>BAR</a>).
It is also possible to use named variables in the pattern, in which case an object is returned, e.g: match(<x><a>{{first:=.}}</a><a>{{second:=.}}</a></x>, <x><a>FOO</a><a>BAR</a></x>) returns an object with two properties "first" and "bar", containing respectively <a>FOO</a> and <a>BAR</a>.
These properties can be accessed like match(<x><a>{{first:=.}}</a><a>{{second:=.}}</a></x>, <x><a>FOO</a><a>BAR</a></x>).first.
Multiple values assigned to the same variable are merged into a single sequence, e.g. match(<x><a>{{res:=.}}</a><a>{{res:=.}}</a></x>, <x><a>FOO</a><a>BAR</a></x>) returns an object with a single property res with value (<a>FOO</a>, <a>BAR</a>) .
If unnamed and named variables are mixed, the unnamed variables are treated like variables with the name _result.
The pattern can be a node or a string. Written as string the above example would be match("<a>{.}</a>", <x><a>FOO</a><a>BAR</a></x>).
You can pass multiple patterns and nodes, in which case each pattern is applied to each node, and the result of all matching calls is returned in a single sequence.
If the pattern cannot be matched, an error is raised.
pxp:read( ) as xs:untypedAtomic
Reads a line from stdin
(Xidel only)
pxp:serialize-json($arg as item()*) as xs:string
Serializes a value as JSON, i.e. converts the value to JSON and converts that to a string.
(available in Xidel and the xquery_json unit)
pxp:system($arg as xs:string) as xs:string
Runs a certain program and returns its stdout result as string.
(Xidel only)

Extension functions (secondary) x:*

Namespace: http://pxp.benibela.dex:argc( ) as integer
Returns the number of command line arguments.
(Xidel only)
x:argv($i as integer) as string
Returns a certain command line argument.
(Xidel only)
x:cps($list as item()*) as item()*
Abbreviation for fn:string-to-codepoints and fn:codepoints-to-string.
x:integer($arg as item()) as xs:integer
x:integer($arg as item(), $base as xs:integer) as xs:integer
Converts a string to an integer. It accepts base-prefixes like 0x or 0b, e.g 0xABCDEF
(Xidel only)
x:integer-to-base($arg as xs:integer, $base as xs:integer) as xs:string
Converts an integer to a string in a certain base.
(Xidel only)
x:lines($text as xs:string?) as xs:string*
Splits a text into lines.
x:product($arg as xs:anyAtomicType*) as xs:anyAtomicType
Calculates the product of a sequence, similar to fn:sum.
x:request($arg as item()*) as object()*
Sends an HTTP request. The request parameters are the same as the value accepted by --follow.
It returns a JSON object with properties "url", "headers", "raw" corresponding to the Xidel default variables listed below. The property "type" contains the content-type, and either "json" or "doc" a JSON or X/HTML document.
(Xidel only)