Hello all,

I'm trying out the server-side javascript in ML 8.

My company stores all of its content in XML format.  We access it using REST 
from javascript UIs, so it's convenient to deliver search results as JSON. I 
know I can do this with XQuery, but I'd like to see if it's even possible in 
Javascript first.

First of all, please verify my assumption that there is no native way in  
javascript to configure a custom transformation from xml to json. Since there 
isn't, I'm using code like this:

var xqueryJson = require("/MarkLogic/json/json");
var config = xqueryJson.config("custom");
config.whitespace = "ignore";
... etc ...

This works, but there are some gotchas. For example, I can configure an array 
element name like so:

config["array-element-names"] = "results"

and it works, XML elements named "results" are transformed into an array in 
json. But it won't do more than one. For example:

// This has no effect. How to do multiple array elements?
var arrayNames = [];
arrayNames.push("results");
arrayNames.push("matches");
config["array-element-names"] = arrayNames;

Is it possible in javascript to configure more than one array element name?

_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to