Revision [1485]
This is an old revision of MarkLogicExists made by DavidLee on 2010-07-10 08:55:05.
Mark Logic Command: exists
Detects if a document exists on a Mark Logic serverSynopsis
exists [-c uri|-connect uri] documentDescription
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 test |
Example
Assuming the prefix "ml" is imported as the marklogic module, tests to see if the directory /test/test.xml existsif 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 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
MarkLogic Extension Module