concat string in for loop
Wednesday, 2 January 2013 · 2 messages
JK
Jarosław Kowalewski2 Jan 2013 21:58 #
Hi,
I've a problem with concatation strings in for loop.
e.g. xquery
concat("text",' ',"additional text"),
' ',
' ',
for $i in <root><a>element-a</a><b>element-b</b></root>/*
return concat($i,' ')give me the result
"
text
additional text
element-a
element-b
"
with additional space before "element-a" and "element-b" but the concatation in the first row works fine. I tried it in GUI mode version 7.3 and 7.5.
Jarek
CG
Christian Grün2 Jan 2013 22:09 #
Cześć, Jaroslwy,
as XML serialization was originally not built for outputting text, the handling of whitespaces is a little tricky. However, you can benefit from the new XQuery 3.0 "item-separator" output option:
declare option output:item-separator '\n';
concat("text",' ',"additional text"),
<root><a>element-a</a><b>element-b</b></root>/*/string()If you want to stick with XQuery 1.0, you can try string-join():
string-join((
"text", "additional text",
<root><a>element-a</a><b>element-b</b></root>/*
), ' ')
Quoted text · Jarosław Kowalewski · 36 lines
On Wed, Jan 2, 2013 at 9:58 PM, Jarosław Kowalewski <jaroslaw.kowalewski at students.waw.pl> wrote: > Hi, > > I've a problem with concatation strings in for loop. > > e.g. xquery > > > concat("text",' ',"additional text"), > ' ', > ' ', > > for $i in <root><a>element-a</a><b>element-b</b></root>/* > return concat($i,' ') > > > give me the result > > " > text > additional text > > element-a > element-b > " > > with additional space before "element-a" and "element-b" but the > concatation in the first row works fine. I tried it in GUI mode > version 7.3 and 7.5. > > Jarek > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 7.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery