fn:document-uri

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

Signatures

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

Properties

The zero-argument form of this function is deterministic, context-dependent, and focus-dependent.

The one-argument form of this function is deterministic, context-independent, and focus-independent.

Rules

If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.

If $arg is the empty sequence, the function returns the empty sequence.

If $arg is not a document node, the function returns the empty sequence.

Otherwise, the function returns the value of the document-uri accessor applied to $arg, as defined in [Data Model (XDM) 3.1] (See Accessors).

Error Conditions

The following errors may be raised when $arg is omitted:

If the context item is absent, dynamic error [ERRXPDY0002]

If the context item is not a node, type error [ERRXPTY0004].

Notes

In the case of a document node $D returned by the fn:doc function, or a document node at the root of a tree containing a node returned by the fn:collection function, it will always be true that either fn:document-uri($D) returns the empty sequence, or that the following expression is true: fn:doc(fn:document-uri($D)) is $D. It is implementation-defined whether this guarantee also holds for document nodes obtained by other means, for example a document node passed as the initial context node of a query or transformation.