Am new to XQuery. I have written below query which is working perfectly and producing results in csv format from an xml stored in Marklogic.
xquery version "0.9-ml"
let $data := someQuery
return
for $i in $data
return
fn:string-join((
$i/PATHTOFILED_1/text(),
$i/PATHTOFILED_2/text(),
.
.
.
.
$i/PATHTOFILED_N/text()
),","
)
Output:
abc,def,adc,
dff,eef,ddf,
.
.
.
.
fff,eed,ddg,
I have a new requirement to add static headers before the data. And the expected output will be like
Expected Output:
HEAD1, HEAD2, HEAD3,
abc,def,adc,
dff,eef,ddf,
.
.
.
.
fff,eed,ddg,
Just adding HEAD1, HEAD2, HEAD3, in the top row. The headers are not part of the XML. They should be part of query in simple Strings with static data and can be modified at anytime in query itself. I have tried to add the below code segment to the query. But the query is not running in Marklogic query console.
concat("HEAD1,"HEAD2","HEAD3"),
Any solution is highly appreciated. Thanks in advance.