Nested Query

I have a document that has for example an element which is itself a doc in the tamino database. Now I want to replace the element with the name doc in tamino.
I thought of having a nested query.
eg.“update replace input()/Doc/name
with for $q in input()/Name return $q” but then I get an error.
Please advice

I’m not sure I understand your description. Let’s say the database has documents “a” and “b”, where “a” has a pointer to the “b” document:

this is the replacement data

You want to modify by replacing with , right? You need to use the FLWU syntax:

update for $bref in input()/a/bRef
do replace $bref
with input()/b[@id=$bref/@id]