However, I am not sure if it is possible at all to mix displaying
(in the "then" part) and updating (in the "else" part)
True - that's actually a limitation of the update specification, wich forbids
mixing updating and non-updating expressions. You can find some information
on it in our documentation [1] and in the actual XQuery specification [2].
As a consequence you have to insert the new query element during a
consecutive query.
If it is possible, I guess I have to include the name of the collection for insertion
by using db:open? Is it necessary to specify the exact place for insertion (as in
my example) as this should be already determined by the condition?
Declaring a variable via the Let expression would help to specify the exact
location only once ... but of course as you have to insert the node during
a second query it's not helping here.
Sorry that I can't provide you with a better solution ... feel free to ask for more.
Best regards,
Lukas