Loading TOC...

MarkLogic Server 11.0 Product Documentation
xdmp.load

xdmp.load(
   path as String,
   [uri as String?],
   [permissions as Object[]],
   [collections as String[]],
   [quality as xs.int?],
   [default-namespace as String?],
   [options as String[]],
   [forest-ids as (Number|String)[]]
) as null

Summary

[DEPRECATED: use xdmp.documentLoad instead] Inserts a new document from the XML file at $path if a document with the specified URI does not already exist. Otherwise, the function replaces the content in the existing document as an update operation.

Parameters
path The path to the input file. The path can be fully qualified or relative. Relative pathnames are resolved from the directory in which MarkLogic Server is installed.
uri The URI of the document to be loaded. If omitted, then the pathname is used.
permissions Security permission objects corresponding to the permissions for the document. If not supplied, the current user's default permissions are applied. The default value used for $permissions can be obtained by calling xdmp:default-permissions(). To specify no permissions, enter the empty sequence ().
collections The collection URIs for collections to which this document belongs. If not supplied, the document is added to the current user's default collections. The default value used for $collections can be obtained by calling xdmp:default-collections(). To specify no collections, enter the empty sequence ().
quality The quality of this document. A positive value increases the relevance score of the document in text search functions. The converse is true for a negative value. The default value is 0.
default-namespace If $default-namespace is specified and the root node of the loaded document does not explicitly specify a namespace, $default-namespace will be applied to the root node. The default value for $default-namespace is "".
options The options for loading this document. The default value is ().

Options include:

"repair-full"
Specifies that malformed XML content be repaired during loading. This option has no effect on binary or text documents.
"repair-none"
Specifies that malformed XML content be rejected during loading. This option has no effect on binary or text documents.
"format-text"
Specifies to load the document as a text document, regardless of the URI specified.
"format-binary"
Specifies to load the document as a binary document, regardless of the URI specified.
"format-xml"
Specifies to load the document as an XML document, regardless of the URI specified.
"format-json"
Specifies to load the document as a JSON document, regardless of the URI specified.
"lang=en"
Specifies that the document is in english.
forest-ids Specifies the ID of the forest in which this document is inserted. If the document already exists in the database, it will remain in its existing forest. If no such forest exists or if no such forest is attached to the context database, an error is raised. If multiple forests are specified, the document is inserted into one of the specified forests.

If you have local disk failover enabled, specify the ID of the master forest. In the event of a failover, MarkLogic server will automatically redirect documents to the replica forest. Specify the ID of the replica forest will result in a "forest not in database" error.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-load

If a new document is inserted, you also need the unprotected-uri privilege (only if the URI is not protected), the any-uri privilege, or an appropriate URI privilege.

Usage Notes

If no format is specified in $options, it is specified by the document content type specified by the extension of the document URI. The mimetype extensions and corresponding content types are set in the Admin Interface.

If neither "repair-full" nor "repair-none" is present, the default is specified by the XQuery version of the caller. In XQuery version 1.0 and 1.0-ml the default is "repair-none". In XQuery version 0.9-ml the default is "repair-full".

Example

declareUpdate();
xdmp.load("/home/test/example.json", "/example.json",
          [xdmp.permission("editor", "read"),
           xdmp.permission("editor", "update")],
          "http://examples.com",
          10,"http://www.marklogic.com/default")

Example

declareUpdate();
xdmp.load("/home/test/example.json",
            "/example.json",
            xdmp.defaultPermissions(),
            xdmp.defaultCollections(),
            0,
            "",
            "repair-none");

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