Hi,
The documentation for xdmp.filesystemFile() (that is the JavaScript
version of it, at https://docs.marklogic.com/xdmp.filesystemFile) says
it returns a `String` object. But it seems to be of a different type.
I use the NPM package `yamljs`, so you can reproduce it, but I think
the example shows clearly the difference without requiring knowledge
of the package. Given you have a file tmp.yaml (e.g. with the content
"---\n foo: bar") then the following code (with an absolute path for
the YAML file):
var yaml = require('./node_modules/yamljs/lib/Yaml.js');
var src = xdmp.filesystemFile('.../tmp.yaml');
yaml.parse(src);
gives the following error:
JS-JAVASCRIPT: if (value.indexOf("\r") !== -1) { -- Error running
JavaScript request: TypeError: undefined is not a function
I assume that `value`, somewhere in the package code, comes from the
parameter to yaml.parse() and is supposed to be a String object,
containing a function `indexOf`. Indeed, if I explicitly create a
String object on the return value of `xdmp.filesystemFile()`, then it
succeeds:
var yaml = require('./node_modules/yamljs/lib/Yaml.js');
var src = xdmp.filesystemFile('.../tmp.yaml');
yaml.parse(new String(src));
The only conclusion I can reach is that the return value of
`xdmp.filesystemFile()` is not a proper String object. Did I miss
anything?
Regards,
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general