The function tries to access an XML text at location specified by document_uri.
If the document_uri argument is node-set, not a string, then a node-set is returned as if document() function is applied to string-value of the first node of the node-set.
The result of call doc($uri) is similar to the call of function document() with default parameters:
document($uri, document-uri(.), 0, 'UTF-8', 'x-any', 'Include=ERROR IdCache=ENABLE')
I.e. the retrieved document should be XML or XHTML (but not an old-style HTML) in 'UTF-8' encoding, content language is 'x-any' (it means 'mix of words from various human languages'), DTD should be read but validation should be disabled; errors on including subdocuments should be reported as errors and thus should abort the processing; a dictionary of element's IDs should be created in order to support XQuery 'pointer operator'.
Node-set
The function may signal variety of errors when it reads the requested document(s) from network or from local resources. It may even cause deadlocks e.g. if documents are retrieved from the Virtuoso's own webserver and these documents must be created on the fly from data that are locked by Virtuoso/PL procedure that invokes the XPATH processor.