In this case there's no path argument, but there is an input argument of
stringXml. Is that how to pass a String to Add()?
There are various ways; one is as follows:
String json = "{ "A": 123 }"; Context ctx = new Context(); new CreateDB("test").execute(ctx); new Set("parser", "json").execute(ctx); Command add = new Add("json.xml"); add.setInput(new ArrayInput(json)); add.execute(ctx); System.out.println(new XQuery(".").execute(ctx));
On Mon, Feb 3, 2020 at 10:16 PM thufir hawat.thufir@gmail.com wrote:
On 2020-02-03 6:46 a.m., Christian Grün wrote:
What does it mean that "if null, the name of input will be set as the path"?
If your path argument points to a directory or a single file, and if you specify no argument for the input variable, the filenames resulting from your first argument will be adopted as database paths.
If you run the command "ADD myfile.xml", the input argument will be null. If you run "ADD TO /db/path myfile.xml", input will be "/db/path".
Right, but I'm not looking to run the command "ADD myfile.xml" from the console but rather:
new Add(null, stringXml).execute(context);
In this case there's no path argument, but there is an input argument of stringXml. Is that how to pass a String to Add()?
thanks,
Thufir