xdmp:document-get( $location as xs:string, [$options as (element()|map:map)?] ) as node()*
Returns the document in the file specified by $location.
Parameters | |
---|---|
location | The location of the input document. If the scheme of the location is HTTP (that is, if the string starts with "http://"), then the document is requested over HTTP. If the scheme is file (that is, if the string starts with "file://"), then the document is requested over file protocol from the local filesystem. Otherwise, the document is fetched from the local filesystem. On the filesystem, the path can be fully qualifed or relative. Relative pathnames are resolved from the directory in which MarkLogic Server is installed. |
options |
Options with which to customize this operation.
You can specify options as either an XML element
in the "xdmp:document-get" namespace, or as a map:map . The
options names below are XML element localnames. When using a map,
replace the hyphens with camel casing. For example, "an-option"
becomes "anOption" when used as a map:map key.
This function supports the following options, as well as options from
xdmp:http-get
when
retrieving content via an HTTP request. Options
from xdmp:http-get must be in the xdmp:http
namespace.
|
http://marklogic.com/xdmp/privileges/xdmp-document-get
If no format is specified in $options, and the document is from an HTTP server, the format is specified by the document content type from the HTTP response. If no format is specified in $options, and the document is from the filesystem, the format is specified by the document content type from the filename extension. The mimetype extensions and corresponding content types are set in the Admin Interface.
When the document is from an HTTP server,
xdmp:document-get
will always return the response
from the HTTP server, even if it is an error response such as 404 or 500. If you
want to be able to examine the response header in your application, use
the xdmp:http-get
instead,
which returns both the response header and the response.
xdmp:document-get("myDocument.xml") => the xml contained in myDocument.xml, for example, <myDocument/>
xdmp:document-get("myDocument.html", <options xmlns="xdmp:document-get"> <repair>full</repair> </options>) => myDocument.html as an XML document that has gone through any needed tag repair
xdmp:document-get("http://myCompany.com/file.xml", <options xmlns="xdmp:document-get" xmlns:http="xdmp:http"> <format>xml</format> <http:authentication> <http:username>user</http:username> <http:password>pass</http:password> </http:authentication> </options>) => gets an XML document named file.xml, sending the authentication credentials user/pass to the http://myCompany.com server
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.