Christian,
many thanks for your elaborations. It seems this is not really a 100% baseX topic any more, but maybe you (or somebody else) can give me another hint anyway.
I agree that the result is somewhat surprising, because you would possibly
expect "/" to return all documents of your collection.
This is exactly what I assumed (and hoped for) :-(
The following query will return the expected results (and it will usually
be evaluated faster if you have indexed your documents):
let $refs := //b/b1/@ref return //a1[@id = $refs]
The problem is that for my application, I require pure xpath expressions (we have a GUI which is configurable by defining tuples of 1. a xpath expression to address data and 2. the desired gui / widget representation). However, if I got the implications of your explanation right, it seems to be impossible to solve my issue by using xpath only as it would require using two different contexts in one and the same expression. Could you (or another xpath pro) confirm this assumption of mine or maybe even come up with an alternate (non-xquery) idea?
TIA Simon