Thanks, Alexander and everybody for your remarks and observations.

As it happens, in the meantime I've found the reason: it is the boundary-space policy, which can either be "preserve" or "strip" and which a boundary-space declaration of the prolog can explicitly choose (overriding the implementation-defined default) [1]. Therefore:

declare boundary-space preserve;
serialize(<e> </e>)

yiels

<e> </e>

as it should, hurray! One of so many opportunities to note the high quality of BaseX which honours such a rather obscure declaration.

The XQuery spec also states explicitly that xml:space has no effect in this context (from [2]):
"Element constructors treat attributes named xml:space as ordinary attributes. An xml:space attribute does not affect the handling of whitespace by an element constructor."

So BaseX is doing just the right thing.

Everything is fine!

Cheers,
Hans-Jürgen

PS: For the interest, here the definition of boundary-whitespace ([2]):
[Definition: Boundary whitespace is a sequence of consecutive whitespace characters within the content of a direct element constructor, that is delimited at each end either by the start or end of the content, or by a DirectConstructor, or by an EnclosedExpr. For this purpose, characters generated by character references such as &#x20; or by CDataSections are not considered to be whitespace characters.]

[1] https://www.w3.org/TR/xquery-31/#id-boundary-space-decls
[2] https://www.w3.org/TR/xquery-31/#id-whitespace



Alexander Holupirek <alex@holupirek.de> schrieb am 11:00 Freitag, 9.September 2016:


> On 08.09.2016, at 23:17, Hans-Juergen Rennau <hrennau@yahoo.de> wrote:

>
> Dear BaseX team,
>
> is this a bug?
>
> serialize(<e>  </e>)
>
> returns
>
> <e/>
>
> I need my blanks!
>
> Hans-Jürgen


Maybe your data is stored/processed with whitespaces stripped off?

http://docs.basex.org/wiki/Options#CHOP