Hello all,
I want to dynamically build a map where the value is an array of maps. I am having a problem with the syntax. (My use-case is to deliver this as JSON for simple ingestion to Spark, by the way).
Here's my test code, which translates cleanly into JSON:
declare option output:method 'json';
map {
"authors": [ map{"fn":"John", "ln":"Smith"}, map{"fn":"Jane", "ln":"Doe"} ]
}
However, when I try to build the same map dynamically, I get the error "Value has more than one item". I guess this is because my for loop is returning a sequence, but I can't figure out the syntax to get it working. Any ideas?
declare option output:method 'json';
map {
"authors": [
(for $b in $authors return (: just assume $authors is populated ...:)
map{"fn":$b/*:given-name/text(), "ln":$b/*:surname/text()})
]
}
TIA!
________________________________
Elsevier B.V. Registered Office: Radarweg 29, 1043 NX Amsterdam, The Netherlands, Registration No. 33156677, Registered in The Netherlands.