Hi Rob,
I think there are various way to achieve that. One way is to store both the full document in the session as well as the path to the requested node:
let $xml := <data><bla><blu/></bla></data>
let $result := $xml//blu
let $path := path($result)
return (
session:set('xml', $xml),
session:set('xml', $path)
)
You can run a dynamic query on the XML snippet to get back your original result:
let $xml := session:get('xml')
let $path := session:get('path')
let $result := xquery:eval($path, { '': $xml })
return $result
Best,
Christian