Loading TOC...

MarkLogic 12 EA 1 Product Documentation
fn.document

fn.document(
   uris as String | String[] | Sequence,
   [base-node as Node]
) as Sequence

Summary

Returns the document(s) stored in the database at the specified URI(s). The URI(s) are resolved according to the base-uri of the calling stylesheet or XQuery main module.

This is an XSLT function, and it is available in both XSLT and in XQuery 1.0-ml.

Parameters
uris The $uris is an array or a Sequence of the URI(s) of the document(s) to be retrieved. This parameter is mandatory. If any URI in this sequence is an absolute URI, then it is used as is. If it is a relative URI, it is resolved against a base URI specified in the second argument.
base-node If $base-node is supplied, its base URI is used to resolve relative URIs in uri-sequence. If it is not supplied, the base URI of the node that contained the fn:document() call is used.

Usage Notes

If no second argument is specified, the URI resolves using the base-uri of the calling module. This can cause surprising results if the URI you are resolving is not rooted but the module from which you call it has a base-uri. When calling fn:document from an xdmp:eval, the calling module is defined to have no base-uri. When calling from an XQuery module or an XSLT stylesheet, the base-uri is the URI of the module or stylesheet. For an example to demonstrate this , see the second example below.

For the URI to be exactly what you enter, use fn:doc instead.

Example

fn.document(["/product.xml", "/price.xml"],
            xdmp.unquote('<a xml:base="http://www.marklogic.com" />'));

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.