Loading TOC...

fn.doc

fn.doc(
   [uri as String | String[] | Sequence]
) as Sequence

Summary

Returns the document(s) stored in the database at the specified URI(s).

If you are only getting a single document (specifying a single URI), you can use cts.doc instead (so you do not need to iterate through the Sequence to get to the document).

Parameters
uri The URI of the document to retrieve. If you omit this parameter, returns all of the documents in the database. If you specify an array or a Sequence of URIs, returns all of the documents at the URIs specified in the list.

Usage Notes

The document-node() returned for each item in the result contains an element() root node for XML documents, a text() root node for text documents, an object-node(), array-node(), or another JSON node for a JSON document, and a binary() root node for binary documents.

Example

const d = fn.doc("/mydocs/doc.json");
for (const x of d) {
x };

=> The variable d holds a Sequence containing the document 
   at the URI /mydocs/doc.json, and x contains the document, so 
   this program returns the document.

Example

const res = [];
const d = fn.subsequence(fn.doc(), 1, 2);
for (const x of d) {
res.push(x); };
res;

=> The first 2 documents in the Sequence containing the documents

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