Hi Artur,
I just found out this all comes down to a mistake in our
XQuery Update documentation - I'm sorry to cause that
confusion.
The XQuery Update specification says this:
If you have an expression like ...
'replace value of node A with B'
the expression B is evaluated with a text node constructor.
That means the result of B is either a sequence of text
nodes or an empty sequence.
Considering your example the outcome is valid - it's the
documentation which is wrong. It's simply not possible to
replace the value of an element node (its descendants)
with other elements. I'll take care of this inconsistency.
Hope this clears things up, thanks for pointing that out!
Regards,
Lukas
PS: I'm also forwarding your answer to basex-talk