Hi Ankit,
let $c := <product><abc>{$b}</abc><bcd>$b</bcd></product>
My question is, Will $c hold all the xml data in main memory or will it contains reference to $a , $b which points to the data in database ?.
The XQuery spec. doesn't actually allow us to point to the original database node, because the embedded node has a different node id:
<abc>{$b}</abc>/* is $b → false
However, the representation of the embedded node resembles the data structure of the original node, so it will take much less memory than an XML fragment that has completely been created in main memory.
Best, Christian