My goal is to generate a CSV file out of XML using Saxon. When running the (simplified!) xquery below in Saxon (PE, 9.7.0.15), in the result for each line after the first result line, an additional space is added:
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
let $document := <A>
<B><C>1</C><D>2</D></B>
<B><C>3</C><D>4</D></B>
<B><C>5</C><D>6</D></B>
</A>
for $b in $document/B
return string-join( for $x in $b/* return $x, "," ) || "
"
the result:
1,2
3,4
5,6
I just cannot get this additional space removed in a 'clean' way (that is: without post processing the result).
Any idea how to generate a 'clean' csv (Text) file?