======Mark Logic Command: exists====== Detects if a document exists on a Mark Logic server ====Synopsis==== exists [-c uri|-connect uri] document ====Description==== Checks to see if a document exists on the MarkLogic server. ||-c,-connect uri||Use the connection string instead of $MLCONNECT|| ||document|| uri of the document to test|| ====Example==== Assuming the prefix "ml" is imported as the marklogic module, tests to see if the directory /test/test.xml exists %% if ml:exists /test/test.xml ; then echo /test/test.xml exists else echo /test/test.xml doesnt exist fi %% Example, safely delete /test/test.xml only if it exists %% ml:exists /test/test.xml && ml:del /test/test.xml %% To check if directory exists use [[MarkLogicDirexists direxists]] ====Implementation==== exists is implemented as an xsh script which simply calls exists(doc(uri)). The source of the script is %% # return true if document exists else return false _opts=$<(xgetopts -a -p "c=connect:,t=text" -ps -- "$@") shift $? :query $_opts -b -q <{{ declare variable $uri external ; exists(doc($uri)) }}> -v uri $1 %% ---- [[ModuleMarkLogic MarkLogic Extension Module]]