Using Marklogic 8 Query Console Javascript on Windows 7

135 views Asked by At

I am just starting to work with Marklogic and I am running simple commands like xdmp.document.load to ingest a json file

declareUpdate();
xdmp.documentLoad("C:\Users\Documents\SemanticData\Recipies\Tofu-Soup.json",
    {
      "uri" : "/documents/tofu-soup.json",
      "permissions" : xdmp.defaultPermissions(),
      "collections" : ["soup", "vegetarian"],
      "encoding" : 'UTF-8'
    })

I receive the following error where the path name has had all the "\" directory separators removed.

[javascript] SVC-FILOPN: xdmp.documentLoad("C:UsersDocumentsSemanticDataRecipiesTofu-Soup.json", {uri:"/documents/tofu-soup.json", permissions:[], collections:["soup", "vegetarian"], ...}) -- File open error: open 'C:UsersDocumentsSemanticDataRecipiesTofu-Soup.json': No such file or directory

I cannot find anything in the functions guide to illuminate me.

Any ideas

2

There are 2 answers

0
grtjn On

Use forward slash, or escape the backslash by doubling it. Backslash is an escape character in JavaScript strings.

HTH!

0
Chakresh Sahu On

You can run command in following way.

declareUpdate();
xdmp.documentLoad("C:\\Users\\Documents\\SemanticData\\Recipies\\Tofu-Soup.json",
    {
      "uri" : "/documents/tofu-soup.json",
      "permissions" : xdmp.defaultPermissions(),
      "collections" : ["soup", "vegetarian"],
      "encoding" : 'UTF-8'
    })