I am trying to get the jQuery autocomplete widget to get the data from XML source stored in the Marklogic XML server.
The XML data is very simple looks like this:
<id>Bank ATM</id>
<id>PostageShipping</id>
<id>WebHosting</id>
<id>ClientParking</id>
Markllogic server does have a function xdmp:to-json that should do something like that, however when used like this
let $ex := fn:collection()//ex:Expense
return xdmp:to-json($ex/ex:id)
It returns the output that looks like that
["fn:doc("/expenses/Expenses-Combined.xml")/ex:Expenses/ex:Expense[1]/ex:id",
"fn:doc("/expenses/Expenses-Combined.xml")/ex:Expenses/ex:Expense[2]/ex:id",
"fn:doc("/expenses/Expenses-Combined.xml")/ex:Expenses/ex:Expense[3]/ex:id",
"fn:doc("/expenses/Expenses-Combined.xml")/ex:Expenses/ex:Expense[4]/ex:id",
"fn:doc("/expenses/Expenses-Combined.xml")/ex:Expenses/ex:Expense[5]/ex:id"]
I tried other jSon serializers for XQuery
and they both have problems of returning very complicated json structures instead of the simple array that jQuery s autocomplete widget would take. Could somebody suggest something?