I am not sure I can understand your XML or quite what you wish to navigate to, however regards hyper-linking from one query to another, it is just all straight-forward HTTP. e.g. you can do something like changing this from:
<th><a href="TO THE PARRENT"><img src="/exist/apps/Obrazki/lupa.jpg" alt="Podrzedny" /> KLIK</a></th>
to:
<th><a href="/exist/rest/db/myquery.xqy?search=parent&current={util:node-id($x)}"><img src="/exist/apps/Obrazki/lupa.jpg" alt="Podrzedny" /> KLIK</a></th>
Obviously above you need to replace /db/myquery.xqy
with the path of your XQuery. In your XQuery you can then use an if/else to decide whether it has been called with the parameters and take a different course of action. e.g.:
if(request:get-parameter("search", ()) eq "search" and request:get-parameter("current", ()))then
let $current := util:node-by-id(doc("/db/Dane/akweny.xml"), request:get-parameter("current", ()))
return
$current (: TODO do something to find the parent instead! :)
else
(: TODO whatever you are already doing :)
Whilst I have used util:node-id
and util:node-by-id
to link from one query to another, I would not really recommend this as these IDs are not stable. Instead you should add an ID to the XML of each record you are interested in addressing directly and use those.