1 Introduction
2 XQuery and XPath Functions
3 XSL Transformations (XSLT) Functions
4 XML Schema
4.1 The schema for fn:analyze-string
4.2 The schema for fn:json-to-xml and fn:xml-to-json
5 Normative References
6 Non-Normative References
This document describes the namespace
http://www.w3.org/2005/xpath-functions defined by the
[XPath and XQuery Functions and Operators 3.1] and [XSLT 3.0]
specifications (October 2014 and
November 2014 versions, respectively).
This namespace is identified by the namespace prefix fn:,
which is a predefined prefix.
For updated information, please refer to the latest version of the
[XPath and XQuery Functions and Operators 3.1] and [XSLT 3.0]
specifications.
This document describes the names that are defined in this namespace at the time of publication. The W3C reserves the right to define additional names in this namespace in the future. [XPath and XQuery Functions and Operators 3.1] and [XSLT 3.0] are the only specifications that may amend this namespace.
This document contains a directory of links to related resources, using RDDL (as defined in [Resource Directory Description Language (RDDL)]).
It is GRDDL-enabled (as defined in [Gleaning Resource Descriptions from Dialects of Languages (GRDDL)]); that is to say that a GRDDL-compliant processor can extract useful RDF (as defined in [Resource Description Framework (RDF): Concepts and Abstract Syntax]) representations of the information contained herein.
This section lists all of the functions defined in the
[XPath and XQuery Functions and Operators 3.1] specification. Each
function and operator is uniquely identified with a URI of the form:
“http://www.w3.org/2005/xpath-functions#name”
where name is the name of a function or operator, such as
“max”: http://www.w3.org/2005/xpath-functions#max.
The normative definitions of these functions are in the [XPath and XQuery Functions and Operators 3.1] specification. For convenience, a very brief, non-normative summary of each function is provided. For details, follow the link on the “Summary:” introductory text below each function.
QName(xs:string?, xs:string) as xs:QName
Returns an xs:QName value formed using a supplied namespace URI and lexical QName.
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.
avg(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.
collection() as item()*
collection(xs:string?) as item()*
Returns a sequence of items identified by a collection URI; or a default collection if no URI is supplied.
count(item()*) as xs:integer
Returns the number of items in a sequence.
current-date() as xs:date
Returns the current date.
current-dateTime() as xs:dateTimeStamp
Returns the current date and time (with timezone).
current-time() as xs:time
Returns the current time.
deep-equal(item()*, item()*) as xs:boolean
deep-equal(item()*, item()*, 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, or maps with matching entries, or arrays with matching members.
default-collation() as xs:string
Returns the value of the default collation property from the static context.
default-language() as xs:language
Returns the value of the default language property from the dynamic context.
distinct-values(xs:anyAtomicType*) as xs:anyAtomicType*
distinct-values(xs:anyAtomicType*, xs:string) as xs:anyAtomicType*
Returns the values that appear in a sequence, with duplicates eliminated.
doc(xs:string?) as document-node()?
Retrieves a document using a URI supplied as an xs:string, and returns the
corresponding document node.
doc-available(xs:string?) as xs:boolean
The function returns true if and only if the function call fn:doc($uri)
would return a document node.
element-with-id(xs:string*) as element()*
element-with-id(xs:string*, 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.
empty(item()*) as xs:boolean
Returns true if the argument is the empty sequence.
environment-variable(xs:string) as xs:string?
Returns the value of a system environment variable, if it exists.
exactly-one(item()*) as item()
Returns $arg if it contains exactly one item. Otherwise, raises an error.
exists(item()*) as xs:boolean
Returns true if the argument is a non-empty sequence.
filter(item()*, function(item()) as xs:boolean) as item()*
Returns those items from the sequence $seq for which the supplied function $f returns true.
fold-left(item()*, item()*, 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.
fold-right(item()*, item()*, 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.
for-each(item()*, function(item()) as item()*) as item()*
Applies the function item $action to every item from the sequence $seq in turn, returning the concatenation of the resulting sequences in order.
for-each-pair(item()*, item()*, function(item(), item()) as item()*) as item()*
Applies the function item $action to successive pairs of items taken one from $seq1 and one from $seq2, returning the concatenation of the resulting sequences in order.
format-date(xs:date?, xs:string) as xs:string?
format-date(xs:date?, xs:string, xs:string?, xs:string?, xs:string?) as xs:string?
Returns a string containing an xs:date value formatted for display.
format-dateTime(xs:dateTime?, xs:string) as xs:string?
format-dateTime(xs:dateTime?, xs:string, xs:string?, xs:string?, xs:string?) as xs:string?
Returns a string containing an xs:dateTime value formatted for display.
format-time(xs:time?, xs:string) as xs:string?
format-time(xs:time?, xs:string, xs:string?, xs:string?, xs:string?) as xs:string?
Returns a string containing an xs:time value formatted for display.
function-arity(function(*)) as xs:integer
Returns the arity of the function identified by a function item.
function-lookup(xs:QName, xs:integer) as function(*)?
Returns the function having a given name and arity, if there is one.
function-name(function(*)) as xs:QName?
Returns the name of the function identified by a function item.
generate-id() as xs:string
generate-id(node()?) as xs:string
This function returns a string that uniquely identifies a given node.
has-children() as xs:boolean
has-children(node()?) as xs:boolean
Returns true if the supplied node has one or more child nodes (of any kind).
head(item()*) as item()?
Returns the first item in a sequence.
id(xs:string*) as element()*
id(xs:string*, 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.
idref(xs:string*) as node()*
idref(xs:string*, 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.
implicit-timezone() as xs:dayTimeDuration
Returns the value of the implicit timezone property from the dynamic context.
in-scope-prefixes(element()) as xs:string*
Returns the prefixes of the in-scope namespaces for an element node.
index-of(xs:anyAtomicType*, xs:anyAtomicType) as xs:integer*
index-of(xs:anyAtomicType*, xs:anyAtomicType, 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.
innermost(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.
insert-before(item()*, xs:integer, item()*) as item()*
Returns a sequence constructed by inserting an item or a sequence of items at a given position within an existing sequence.
lang(xs:string?) as xs:boolean
lang(xs:string?, 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.
last() as xs:integer
Returns the context size from the dynamic context.
local-name() as xs:string
local-name(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.
local-name-from-QName(xs:QName?) as xs:NCName?
Returns the local part of the supplied QName.
max(xs:anyAtomicType*) as xs:anyAtomicType?
max(xs:anyAtomicType*, xs:string) as xs:anyAtomicType?
Returns a value that is equal to the highest value appearing in the input sequence.
min(xs:anyAtomicType*) as xs:anyAtomicType?
min(xs:anyAtomicType*, xs:string) as xs:anyAtomicType?
Returns a value that is equal to the lowest value appearing in the input sequence.
name() as xs:string
name(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.
namespace-uri() as xs:anyURI
namespace-uri(node()?) as xs:anyURI
Returns the namespace URI part of the name of $arg, as an
xs:anyURI value.
namespace-uri-for-prefix(xs:string?, element()) as xs:anyURI?
Returns the namespace URI of one of the in-scope namespaces for $element,
identified by its namespace prefix.
namespace-uri-from-QName(xs:QName?) as xs:anyURI?
Returns the namespace URI part of the supplied QName.
node-name() as xs:QName?
node-name(node()?) as xs:QName?
Returns the name of a node, as an xs:QName.
number() as xs:double
number(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.
one-or-more(item()*) as item()+
Returns $arg if it contains one or more items. Otherwise, raises an error.
outermost(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.
parse-ietf-date(xs:string?) as xs:dateTime?
Parses a string containing the date and time in IETF format, returning the corresponding
xs:dateTime value.
parse-xml(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.
parse-xml-fragment(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.
path() as xs:string?
path(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.
position() as xs:integer
Returns the context position from the dynamic context.
prefix-from-QName(xs:QName?) as xs:NCName?
Returns the prefix component of the supplied QName.
random-number-generator() as map(xs:string, item())
random-number-generator(xs:anyAtomicType?) as map(xs:string, item())
Returns a random number generator, which can be used to generate sequences of random numbers.
remove(item()*, xs:integer) as item()*
Returns a new sequence containing all the items of $target except the item
at position $position.
resolve-QName(xs:string?, 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.
reverse(item()*) as item()*
Reverses the order of items in a sequence.
root() as node()
root(node()?) as node()?
Returns the root of the tree to which $arg belongs. This will usually, but
not necessarily, be a document node.
serialize(item()*) as xs:string
serialize(item()*, item()?) as xs:string
This function serializes the supplied input sequence $arg as described in
[xslt-xquery-serialization-31], returning the serialized representation
of the sequence as a string.
static-base-uri() as xs:anyURI?
This function returns the value of the static base URI property from the static context.
subsequence(item()*, xs:double) as item()*
subsequence(item()*, xs:double, 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.
sum(xs:anyAtomicType*) as xs:anyAtomicType
sum(xs:anyAtomicType*, xs:anyAtomicType?) as xs:anyAtomicType?
Returns a value obtained by adding together the values in $arg.
tail(item()*) as item()*
Returns all but the first item in a sequence.
unordered(item()*) as item()*
Returns the items of $sourceSeq in an implementation-dependent order.
unparsed-text(xs:string?) as xs:string?
unparsed-text(xs:string?, 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.
unparsed-text-available(xs:string?) as xs:boolean
unparsed-text-available(xs:string?, xs:string) as xs:boolean
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.
unparsed-text-lines(xs:string?) as xs:string*
unparsed-text-lines(xs:string?, 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.
uri-collection() as xs:anyURI*
uri-collection(xs:string?) as xs:anyURI*
Returns a sequence of xs:anyURI values representing the URIs in a URI
collection.
zero-or-one(item()*) as item()?
Returns $arg if it contains zero or one items. Otherwise, raises an
error.
This section lists all of the functions defined in the
[XSLT 3.0] specification. Each
function and operator is uniquely identified with a URI of the form:
“http://www.w3.org/2005/xpath-functions#name”
where name is the name of a function or operator, such as
“system-property”: http://www.w3.org/2005/xpath-functions#system-property.
The normative definitions of these functions are in the [XSLT 3.0] specification. For convenience, a very brief, non-normative summary of each function is provided. For details, follow the link on the “Summary:” introductory text below each function.
accumulator-after(xs:string) as item()*
Returns the post-descent value of the selected accumulator at the context node.
accumulator-before(xs:string) as item()*
Returns the pre-descent value of the selected accumulator at the context node.
available-system-properties() as xs:QName*
Returns a list of system property names that are suitable for passing to
the system-property function, as a sequence of QNames.
collation-key(xs:string) as xs:base64Binary
collation-key(xs:string, xs:string) as xs:base64Binary
Given a string value and a collation, generates an internal value called a collation key, with the property that the matching and ordering of collation keys reflects the matching and ordering of strings under the specified collation.
contains(map(*), xs:anyAtomicType) as xs:boolean
Tests whether a supplied map contains an entry for a given key
copy-of() as item()
copy-of(item()*) as item()*
Returns a deep copy of the sequence supplied as the $input argument, or of the
context item if the argument is absent.
current() as item()
Returns the item that is the context item for the evaluation of the containing XPath expression
current-group() as item()*
Returns the group currently being processed by an xsl:for-each-group
instruction.
current-grouping-key() as xs:anyAtomicType*
Returns the grouping key of the group currently being processed using the
xsl:for-each-group
instruction.
current-merge-group() as item()*
current-merge-group(xs:string) as item()*
Returns the group of items currently being processed by an xsl:merge
instruction.
current-merge-key() as xs:anyAtomicType*
Returns the merge key of the
merge group currently being processed using the
xsl:merge instruction.
current-output-uri() as xs:anyURI?
Returns the value of the .
deep-equal(item()*, item()*) as xs:boolean
deep-equal(item()*, item()*, xs:string) as xs:boolean
This function assesses whether two sequences are deep-equal to each other. The function
as described here extends the definition of the XPath 3.0
deep-equal to explain how it should handle maps; it is
intended to replace the existing deep-equal function at some
stage in the future.
document(item()*) as node()*
document(item()*, node()) as node()*
Provides access to XML documents identified by a URI.
element-available(xs:string) as xs:boolean
Determines whether a particular instruction is or is not available for use. The function
is particularly useful for calling within an [xsl:]use-when attribute (see
) to test whether a particular is available.
entry(xs:anyAtomicType, item()*) as map(*)
Returns a map that contains a single entry (a key-value pair).
find(item()*, xs:anyAtomicType) as array(*)
Searches the supplied input sequence and any contained maps and arrays for a map entry with the supplied key, and returns the corresponding values.
for-each(map(*), function(xs:anyAtomicType, item()*) as item()*) as item()*
Applies a supplied function to every entry in a map, returning the concatenation of the results.
function-available(xs:string) as xs:boolean
function-available(xs:string, xs:integer) as xs:boolean
Determines whether a particular function is or is not available for use. The function
is
particularly useful for calling within an [xsl:]use-when attribute (see
) to test whether a particular is available.
get(map(*), xs:anyAtomicType) as item()*
Returns the value associated with a supplied key in a given map.
json-to-xml(xs:string) as document-node()
json-to-xml(xs:string, map(*)) as document-node()
Parses a string supplied in the form of a JSON text, returning the results in the form of an XML document node.
key(xs:string, xs:anyAtomicType*) as node()*
key(xs:string, xs:anyAtomicType*, node()) as node()*
Returns the nodes that match a supplied key value.
keys(map(*)) as xs:anyAtomicType*
Returns a sequence containing all the keys present in a map
merge(map(*)*) as map(*)
merge(map(*)*, map(*)) as map(*)
Returns a map that combines the entries from a number of existing maps.
put(map(*), xs:anyAtomicType, item()*) as map(*)
Returns a map containing all the contents of the supplied map, but with an additional entry, which replaces any existing entry for the same key.
regex-group(xs:integer) as xs:string
Returns the string captured by a parenthesized subexpression of the regular expression
used during evaluation of the xsl:analyze-string instruction.
remove(map(*), xs:anyAtomicType*) as map(*)
Returns a map containing all the entries from a supplied map, except those having a specified key.
same-key(xs:anyAtomicType, xs:anyAtomicType) as xs:boolean
Determines whether two atomic values can coexist as separate keys within a map.
size(map(*)) as xs:integer
Returns the number of entries in the supplied map.
snapshot() as item()
snapshot(item()*) as item()*
Returns a copy of a sequence, retaining copies of the ancestors and descendants of any node in the input sequence, together with their attributes and namespaces.
stream-available(xs:string?) as xs:boolean
Determines, as far as possible, whether a document is available for streamed processing
using xsl:source-document.
system-property(xs:string) as xs:string
Returns the value of a system property
type-available(xs:string) as xs:boolean
Used to control how a stylesheet behaves if a particular schema type is or is not available in the static context.
unparsed-entity-public-id(xs:string) as xs:string
unparsed-entity-public-id(xs:string, node()) as xs:string
Returns the public identifier of an unparsed entity
unparsed-entity-uri(xs:string) as xs:anyURI
unparsed-entity-uri(xs:string, node()) as xs:anyURI
Returns the URI (system identifier) of an unparsed entity
xml-to-json(node()?) as xs:string?
xml-to-json(node()?, map(*)) as xs:string?
Converts an XML tree, whose format corresponds to the XML representation of JSON defined in this specification, into a string conforming to the JSON grammar.
Two functions, fn:analyze-string and fn:json-to-xml, return results that
are always valid according to a defined XSD schema. A third function, fn:xml-to-json,
requires input that is valid according to this schema.
The target namespace of these schema components is http://www.w3.org/2005/xpath-functions.
The function fn:analyze-string(), identified in section 2 XQuery and XPath Functions above,
returns results that are always valid according to an XML Schema specified in [XPath
and XQuery Functions and Operators 3.1].
That XML Schema defines four XML elements and three XML Schema complex types. The
XML elements are named:
<analyze-string-result>
<match>
<non-match>
<group>
The XML Schema complex types are named:
analyze-string-result-type
match-type
group-type
These schema components define the XML syntax of the result returned by fn:analyze-string as defined in
[XPath and XQuery Functions and Operators 3.1].
They are specified in a schema document located at
http://www.w3.org/2014/11/xslt-30/analyze-string.xsd.
The function fn:json-to-xml(), identified in section 2 XQuery and XPath Functions above,
returns results that are always valid according to an XML Schema specified in [XPath
and XQuery Functions and Operators 3.1].
The function fn:xml-to-json(), likewise, requires its input to be valid against this schema.
That XML Schema defines six global element declarations and five XML Schema complex
types. The element declarations are named:
<map>
<array>
<string>
<number>
<boolean>
<null>
The XML Schema complex types are named:
mapType
arrayType
stringType
numberType
nullType
These schema components define the XML syntax of the result returned by fn:json-to-xml as defined in
[XSLT 3.0].
They are specified in a schema document located at
http://www.w3.org/2014/11/xslt-30/schema-for-json.xsd.
These documents describe the names that are defined in this namespace at the time of publication. The W3C reserves the right to define additional names in this namespace in the future.
XPath and XQuery Functions and Operators 3.1 (1 October 2014 version)
XSL Transformations (XSLT) 3.0 (19 November 2014 version)
Resource Directory Description Language (RDDL) (4 July 2007)
Gleaning Resource Descriptions from Dialects of Languages (GRDDL) (Recommendation of 11 September 2007)
Resource Description Framework (RDF): Concepts and Abstract Syntax (Recommendation of 10 February 2004)