I've just started using Xquery with Xqilla.
I want my result to be returned with correct indentation and newlines.
I have a list of directors called $duplicates, and I want to fetch all movie titles from these directors within my return statement.
My return statement:
for $duplicate in $duplicates
return
<movie director="{$duplicate}">
{$result/videos/video/title[../director=$duplicate]}</movie>
Which I want to be formatted (kind of) like this:
<movie director="Coppola">
<title>The Godfather</title>
<title>The Godfather pt. 2</title>
<title>Apocalypse Now</title></movie>
with the children properly indented, each on a new line.
What I'm getting is this:
<movie director="Coppola">
<title>The Godfather</title><title>The Godfather pt. 2</title><title>Apocalypse Now</title></movie>
with all of the titles in a single row.
Since I've successfully returned a list of titles before by simply returning a variable
I tried a nested return statement with a for-loop as suggested on wikibooks. This solution also contained explicitly defined <title>
-tags.
I found one person with the same problem here on SO.
The answer there did not work. When I added a namespace my program stopped outputting completely. I'd also prefer it if there was some non-kludge solution (which there seems to be since everyone seems to be getting perfect output right from the start).
The problem seems to be about mixing XML and Xquery with curly bracket usage.