1. XPath Built-in Functions

    XPath 3.0 contains a wealth of built-in functions which can be used in XPath expressions. The functions are defined in the XPath and XQuery Functions and Operators 3.0 specification. This section categorizes the functions according to 'domain' and links to the function definitions in the specification:

    1. Accessors

      fn:node-name() as xs:QName?	
      fn:node-name($arg as node()?) as xs:QName?

      Returns the name of a node, as an xs:QName.

      fn:nilled() as xs:boolean	
      fn:nilled($arg as node()?) as xs:boolean?

      Returns true for an element that is nilled.

      fn:string() as xs:string	
      fn:string($arg as item()?) as xs:string

      Returns the value of $arg represented as an xs:string.

      fn:data() as xs:anyAtomicType*	
      fn:data($arg as item()*) as xs:anyAtomicType*

      Returns the result of atomizing a sequence, that is, replacing all nodes in the sequence by their typed values.

      fn:base-uri() as xs:anyURI?	
      fn:base-uri($arg as node()?) as xs:anyURI?

      Returns the base URI of a node.

      fn:document-uri() as xs:anyURI?	
      fn:document-uri($arg as node()?) as xs:anyURI?

      Returns the URI of a resource where a document can be found, if available.

    2. Numeric Functions

      1. Functions on Numbers

        fn:abs($arg as numeric?) as numeric?

        Returns the absolute value of $arg.

        fn:ceiling($arg as numeric?) as numeric?

        Rounds $arg upwards to a whole number.

        fn:floor($arg as numeric?) as numeric?

        Rounds $arg downwards to a whole number.

        fn:round($arg as numeric?) as numeric?	
        fn:round($arg as numeric?, $precision as xs:integer) as numeric?

        Rounds a value to a specified number of decimal places, rounding upwards if two such values are equally near.

        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.

      2. Parsing Numbers

        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.

      3. Formatting Numbers

        fn:format-number($value as numeric?, $picture as xs:string) as xs:string	
        fn:format-number($value as numeric?, $picture as xs:string, $decimal-format-name as xs:string?) as xs:string

        Returns a string containing a number formatted according to a given picture string, taking account of decimal formats specified in the static context.

      4. Formatting Integers

        fn:format-integer($value as xs:integer?, $picture as xs:string) as xs:string	
        fn:format-integer($value as xs:integer?, $picture as xs:string, $lang as xs:string?) as xs:string

        Formats an integer according to a given picture string, using the conventions of a given natural language if specified.

      5. Trigonometric and exponential functions

        math:pi() as xs:double

        Returns an approximation to the mathematical constant π.

        math:exp($arg as xs:double?) as xs:double?

        Returns the value of ex.

        math:exp10($arg as xs:double?) as xs:double?

        Returns the value of 10x.

        math:log($arg as xs:double?) as xs:double?

        Returns the natural logarithm of the argument.

        math:log10($arg as xs:double?) as xs:double?

        Returns the base-ten logarithm of the argument

        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.

        math:sqrt($arg as xs:double?) as xs:double?

        Returns the non-negative square root of the argument.

        math:sin($θ as xs:double?) as xs:double?

        Returns the sine of the argument, expressed in radians.

        math:cos($θ as xs:double?) as xs:double?

        Returns the cosine of the argument, expressed in radians.

        math:tan($θ as xs:double?) as xs:double?

        Returns the tangent of the argument, expressed in radians.

        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.

        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.

        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.

        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 +π.

    3. String Functions

      1. Functions to assemble and disassemble strings

        fn:codepoints-to-string($arg as xs:integer*) as xs:string

        Creates an xs:string from a sequence of codepoints.

        fn:string-to-codepoints($arg as xs:string?) as xs:integer*

        Returns the sequence of codepoints that constitute an xs:string value.

      2. Comparison of strings

        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.

        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.

      3. Functions on string values

        fn:concat($arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType?, ... ) as xs:string

        Returns the concatenation of the string values of the arguments.

        fn:string-join($arg1 as xs:string*) as xs:string	
        fn:string-join($arg1 as xs:string*, $arg2 as xs:string) as xs:string

        Returns a string created by concatenating the items in a sequence, with a defined separator between adjacent items.

        fn:substring($sourceString as xs:string?, $start as xs:double) as xs:string	
        fn:substring($sourceString as xs:string?, $start 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.

        fn:string-length() as xs:integer	
        fn:string-length($arg as xs:string?) as xs:integer

        Returns the number of characters in a string.

        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.

        fn:normalize-unicode($arg as xs:string?) as xs:string	
        fn:normalize-unicode($arg as xs:string?, $normalizationForm as xs:string) as xs:string

        Returns the value of $arg after applying Unicode normalization.

        fn:upper-case($arg as xs:string?) as xs:string

        Converts a string to upper case.

        fn:lower-case($arg as xs:string?) as xs:string

        Converts a string to lower case.

        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.

      4. Functions based on substring matching

        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.

        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.

        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.

        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.

        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.

      5. String functions that use regular expressions

        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.

        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.

        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.

        fn:analyze-string($input as xs:string?, $pattern as xs:string) as element (fn:analyze-string-result)	
        fn:analyze-string($input as xs:string?, $pattern as xs:string, $flags as xs:string) as element(fn:analyze-string-result)

        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.

    4. Functions that manipulate URIs

      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.

      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.

      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].

      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

    5. Functions on Boolean values

      1. Boolean constant functions

        fn:true() as xs:boolean

        Returns the xs:boolean value true.

        fn:false() as xs:boolean

        Returns the xs:boolean value false.

      2. Functions on boolean values

        fn:boolean($arg as item()*) as xs:boolean

        Computes the effective boolean value of the sequence $arg.

        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.

    6. Functions on durations

      1. Component extraction functions on durations

        fn:years-from-duration($arg as xs:duration?) as xs:integer?

        Returns the number of years in a duration.

        fn:months-from-duration($arg as xs:duration?) as xs:integer?

        Returns the number of months in a duration.

        fn:days-from-duration($arg as xs:duration?) as xs:integer?

        Returns the number of days in a duration.

        fn:hours-from-duration($arg as xs:duration?) as xs:integer?

        Returns the number of hours in a duration.

        fn:minutes-from-duration($arg as xs:duration?) as xs:integer?

        Returns the number of minutes in a duration.

        fn:seconds-from-duration($arg as xs:duration?) as xs:decimal?

        Returns the number of seconds in a duration.

    7. Functions on dates and times

      1. Constructing a dateTime

        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

      2. Component extraction functions on dates and times

        fn:year-from-dateTime($arg as xs:dateTime?) as xs:integer?

        Returns the year component of an xs:dateTime.

        fn:month-from-dateTime($arg as xs:dateTime?) as xs:integer?

        Returns the month component of an xs:dateTime.

        fn:day-from-dateTime($arg as xs:dateTime?) as xs:integer?

        Returns the day component of an xs:dateTime.

        fn:hours-from-dateTime($arg as xs:dateTime?) as xs:integer?

        Returns the hours component of an xs:dateTime.

        fn:minutes-from-dateTime($arg as xs:dateTime?) as xs:integer?

        Returns the minutes component of an xs:dateTime.

        fn:seconds-from-dateTime($arg as xs:dateTime?) as xs:integer?

        Returns the seconds component of an xs:dateTime.

        fn:timezone-from-dateTime($arg as xs:dateTime?) as xs:dayTimeDuration?

        Returns the timezone component of an xs:dateTime.

        fn:year-from-date($arg as xs:date?) as xs:integer?

        Returns the year component of an xs:date.

        fn:month-from-date($arg as xs:date?) as xs:integer?

        Returns the month component of an xs:date.

        fn:day-from-date($arg as xs:date?) as xs:integer?

        Returns the month component of an xs:date.

        fn:timezone-from-date($arg as xs:date?) as xs:dayTimeDuration?

        Returns the timezone component of an xs:date.

        fn:hours-from-time($arg as xs:time?) as xs:integer?

        Returns the hours component of an xs:time.

        fn:minutes-from-time($arg as xs:time?) as xs:integer?

        Returns the minutes component of an xs:time.

        fn:seconds-from-time($arg as xs:time?) as xs:integer?

        Returns the seconds component of an xs:time.

        fn:timezone-from-time($arg as xs:time?) as xs:dayTimeDuration?

        Returns the timezone component of an xs:time.

      3. Timezone adjustment functions on dates and times

        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.

        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.

        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.

      4. Formatting dates and times

        fn:format-dateTime($value as xs:dateTime?, $picture as xs:string) as xs:string?	
        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?

        Returns a string containing an xs:dateTime value formatted for display.

        fn:format-date($value as xs:date?, $picture as xs:string) as xs:string?	
        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?

        Returns a string containing an xs:date value formatted for display.

        fn:format-time($value as xs:time?, $picture as xs:string) as xs:string?	
        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?

        Returns a string containing an xs:time value formatted for display.

      1. Functions to create a QName

        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.

        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.

      2. fn:prefix-from-QName($arg as xs:QName?) as xs:NCName?

        Returns the prefix component of the supplied QName.

        fn:local-name-from-QName($arg as xs:QName?) as xs:NCName?

        Returns the local part of the supplied QName.

        fn:namespace-uri-from-QName($arg as xs:QName?) as xs:anyURI?

        Returns the namespace URI part of the supplied QName.

        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

        fn:in-scope-prefixes($element as element()) as xs:string*

        Returns the prefixes of the in-scope namespaces for an element node.

    8. Functions on nodes

      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.

      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.

      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

      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.

      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.

      fn:path() as xs:string?	
      fn:path($arg as node()?) as xs:string?

      Returns a path expression that can be used to select the supplied node relative to the root of its containing document.

      fn:has-children() as xs:boolean	
      fn:has-children($node as node()?) as xs:boolean

      Returns true if the supplied node has one or more child nodes (of any kind).

      fn:innermost($nodes as node()*) as node()*

      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.

      fn:outermost($nodes as node()*) as node()*

      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

    9. Functions on sequences

      1. General functions on sequences

        fn:empty($arg as item()*) as xs:boolean

        Returns true if the argument is the empty sequence.

        fn:exists($arg as item()*) as xs:boolean

        Returns true if the argument is a non-empty sequence.

        fn:head($arg as item()*) as item()?

        Returns the first item in a sequence.

        fn:tail($arg as item()*) as item()*

        Returns all but the first item in a sequence.

        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.

        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.

        fn:reverse($arg as item()*) as item()*

        Reverses the order of items in a sequence.

        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.

        fn:unordered($sourceSeq as item()*) as item()*

        Returns the items of $sourceSeq in an implementation dependent order.

      2. Functions that compare values in sequences

        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.

        fn:index-of($seq as xs:anyAtomicType*, $search as xs:anyAtomicType) as xs:integer*	
        fn:index-of($seq as xs:anyAtomicType*, $search 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.

        fn:deep-equal($parameter1 as item()*, $parameter2 as item()*) as xs:boolean	
        fn:deep-equal($parameter1 as item()*, $parameter2 as item()*, $collation as xs: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.

      3. Functions that test the cardinality of sequences

        fn:zero-or-one($arg as item()*) as item()?

        Returns $arg if it contains zero or one items. Otherwise, raises an error.

        fn:one-or-more($arg as item()*) as item()+

        Returns $arg if it contains one or more items. Otherwise, raises an error.

        fn:exactly-one($arg as item()*) as item()

        Returns $arg if it contains exactly one item. Otherwise, raises an error.

      4. Aggregate Functions

        fn:count($arg as item()*) as xs:integer

        Returns the number of items in a sequence.

        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.

        fn:max($arg as xs:anyAtomicType*) as xs:anyAtomicType?	
        fn:max($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType?

        Returns a value that is equal to the highest value appearing in the input sequence.

        fn:min($arg as xs:anyAtomicType*) as xs:anyAtomicType?	
        fn:min($arg as xs:anyAtomicType*, $collation as xs:string) as xs:anyAtomicType?

        Returns a value that is equal to the lowest value appearing in the input sequence.>

        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.

      5. Functions on node identifiers

        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.

        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.

        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.

        fn:generate-id() as xs:string	
        fn:generate-id($arg as node()?) as xs:string

        This function returns a string that uniquely identifies a given node.

      6. Functions giving access to external information

        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.

        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.

        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.

        fn:uri-collection() as xs:anyURI*	
        fn:uri-collection($arg as xs:string?) as xs:anyURI*

        Returns a sequence of xs:anyURI values representing the URIs in a resource collection.

        fn:unparsed-text($href as xs:string?) as xs:string?	
        fn:unparsed-text($href as xs:string?, $encoding as xs:string) as xs:string?

        The fn:unparsed-text function reads an external resource (for example, a file) and returns a string representation of the resource.

        fn:unparsed-text-lines($href as xs:string?) as xs:string*	
        fn:unparsed-text-lines($href as xs:string?, $encoding as xs:string) as xs:string*

        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.

        fn:unparsed-text-lines($href as xs:string?) as xs:string*	
        fn:unparsed-text-lines($href as xs:string?, $encoding as xs:string) as xs:string*

        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.

        fn:environment-variable($name as xs:string) as xs:string?

        Returns the value of a system environment variable, if it exists.

        fn:available-environment-variables() as xs:string*

        Returns a list of environment variable names that are suitable for passing to fn:environment-variable, as a (possibly empty) sequence of strings.

      7. Parsing and serializing

        fn:parse-xml($arg as xs:string?) as document-node(element(*))?

        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.

        fn:parse-xml-fragment($arg as xs:string?) as document-node()?

        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.

        fn:serialize($arg as item()*) as xs:string	
        fn:serialize( $arg as item()*, $params as element(output:serialization-parameters)?) as xs:string

        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.

    10. Context functions

      fn:position() as xs:integer

      Returns the context position from the dynamic context.

      fn:last() as xs:integer

      Returns the context size from the dynamic context.

      fn:current-dateTime() as xs:dateTimeStamp

      Returns the current date and time (with timezone).

      fn:current-date() as xs:date

      Returns the current date.

      fn:current-time() as xs:time

      Returns the current time.

      fn:implicit-timezone() as xs:dayTimeDuration

      Returns the value of the implicit timezone property from the dynamic context.

      fn:default-collation() as xs:string

      Returns the value of the default collation property from the static context.

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

      This function returns the value of the Static Base URI property from the static context.

    11. Higher-order functions

      1. Functions on functions

        fn:function-lookup($name as xs:QName, $arity as xs:integer) as function(*)?

        Returns the function having a given name and arity, if there is one.

        fn:function-name

        Returns the name of the function identified by a function item.

        fn:function-arity($func as function(*)) as xs:integer

        Returns the arity of the function identified by a function item.

      2. Basic higher-order functions

        fn:for-each($seq as item()*, $f as function(item()) as item()*) as item()*

        Applies the function item $f to every item from the sequence $seq in turn, returning the concatenation of the resulting sequences in order.

        fn:filter

        Returns those items from the sequence $seq for which the supplied function $f returns true.

        fn:fold-left($seq as item(),$zero as item()*, $f as function(item()*, item()) as item()*) as item()*

        Processes the supplied sequence from left to right, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

        fn:fold-right($seq as item()*, $zero as item()*, $f as function(item()*, item()) as item()*) as item()*

        Processes the supplied sequence from right to left, applying the supplied function repeatedly to each item in turn, together with an accumulated result value.

        fn:for-each-pair($seq1 as item()*, $seq2 as item()*, $f as function(item(), item()) as item()*) as item()*

        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.

    12. Constructor functions

      Constructor functions allow values of a particular type to be created in XPath expressions.

      1. Constructor functions for XML Schema built-in atomic XML Schema types

        Every built-in atomic type defined in the XML Schema datatypes specification (except for 'xs:anyAtomicType' and 'xs:NOTATION') has an associated constructor function which takes the form eg:TYPE($arg as xs:anyAtomicType?) as eg:TYPE?.

        For example, the 'xs:date' constructor function could be called with a string value representing the date i.e. xs:date('2014-11-16') to create a value of type 'xs:date.'

        xs:anyURI($arg as xs:anyAtomicType?) as xs:anyURI?
        xs:base64Binary($arg as xs:anyAtomicType?) as xs:base64Binary?
        xs:boolean($arg as xs:anyAtomicType?) as xs:boolean?
        xs:byte($arg as xs:anyAtomicType?) as xs:byte?
        xs:date($arg as xs:anyAtomicType?) as xs:date?
        xs:dateTime($arg as xs:anyAtomicType?) as xs:dateTime?
        xs:dayTimeDuration($arg as xs:anyAtomicType?) as xs:dayTimeDuration?
        xs:decimal($arg as xs:anyAtomicType?) as xs:decimal?
        xs:double($arg as xs:anyAtomicType?) as xs:double?
        xs:duration($arg as xs:anyAtomicType?) as xs:duration?
        xs:ENTITY($arg as xs:anyAtomicType?) as xs:ENTITY?
        xs:float($arg as xs:anyAtomicType?) as xs:float?
        xs:gDay($arg as xs:anyAtomicType?) as xs:gDay?
        xs:gMonth($arg as xs:anyAtomicType?) as xs:gMonth?
        xs:gMonthDay($arg as xs:anyAtomicType?) as xs:gMonthDay?
        xs:gYear($arg as xs:anyAtomicType?) as xs:gYear?
        xs:gYearMonth($arg as xs:anyAtomicType?) as xs:gYearMonth?
        xs:hexBinary($arg as xs:anyAtomicType?) as xs:hexBinary?
        xs:ID($arg as xs:anyAtomicType?) as xs:ID?
        xs:IDREF($arg as xs:anyAtomicType?) as xs:IDREF?
        xs:int($arg as xs:anyAtomicType?) as xs:int?
        xs:integer($arg as xs:anyAtomicType?) as xs:integer?
        xs:language($arg as xs:anyAtomicType?) as xs:language?
        xs:long($arg as xs:anyAtomicType?) as xs:long?
        xs:Name($arg as xs:anyAtomicType?) as xs:Name?
        xs:NCName($arg as xs:anyAtomicType?) as xs:NCName?
        xs:NMTOKEN($arg as xs:anyAtomicType?) as xs:NMTOKEN?
        xs:negativeInteger($arg as xs:anyAtomicType?) as xs:negativeInteger?
        xs:nonNegativeInteger($arg as xs:anyAtomicType?) as xs:nonNegativeInteger?
        xs:nonPositiveInteger($arg as xs:anyAtomicType?) as xs:nonPositiveInteger?
        xs:normalizedString($arg as xs:anyAtomicType?) as xs:normalizedString?
        xs:positiveInteger($arg as xs:anyAtomicType?) as xs:positiveInteger?
        xs:short($arg as xs:anyAtomicType?) as xs:short?
        xs:string($arg as xs:anyAtomicType?) as xs:string?
        xs:time($arg as xs:anyAtomicType?) as xs:time?
        xs:token($arg as xs:anyAtomicType?) as xs:token?
        xs:unsignedByte($arg as xs:anyAtomicType?) as xs:unsignedByte?
        xs:unsignedInt($arg as xs:anyAtomicType?) as xs:unsignedInt?
        xs:unsignedLong($arg as xs:anyAtomicType?) as xs:unsignedLong?
        xs:unsignedShort($arg as xs:anyAtomicType?) as xs:unsignedShort?
        xs:untypedAtomic($arg as xs:anyAtomicType?) as xs:untypedAtomic?
        xs:yearMonthDuration($arg as xs:anyAtomicType?) as xs:yearMonthDuration?
      2. Constructor functions for XML Schema built-in list types

        XML Schema also contains three list types for which there are also constructor functions. List types are simple types whose value is a space delimited list of items.

        xs:NMTOKENS($arg as xs:anyAtomicType?) as xs:NMTOKEN*
        xs:ENTITIES($arg as xs:anyAtomicType?) as xs:ENTITY*
        xs:IDREFS($arg as xs:anyAtomicType?) as xs:IDREF*
      3. Constructor functions for user defined simple types

        XML Schema allows user-defined simple types to be derived from existing built-in simple types or from other user-defined simple types. Constructor functions are available for user-defined types as well, provided that these are defined in an XSD schema document which is associated with an XML document (and thus made available to the XPath processor).

        zip:postal-code($arg as xs:anyAtomicType?) as zip:postal-code

        This constructor constructs a type of 'zip:postal-code', where 'postal-code' is a user-defined simpletype defined in the namespace bound to the 'zip' prefix.