Good news Dave, I found an obvious solution for your observation (I've readded a context item check that had been removed some time ago due to some mystic reason). Please check out the latest sources.
Christian
On Wed, Jun 23, 2010 at 5:16 PM, Christian Grün christian.gruen@gmail.com wrote:
But what about the case with the for expression...
Query: for $p in count(./preceding-sibling::*)+1 return /test/a/ab/*[$p] Result: <aba><abb><abc> (was expecting just <abb> as before)
Is the value of $p not evaluated until it's used from within the return?
True; by dumping the query info I found that the 'for' expression is optimized as follows…
/test/a/ab/*[count(preceding-sibling::*) + 1]
…which is unexpected if you have predefined a context item, such as in your case (by default, you'll get the appropriate error mesage that the context item has not been specified). This one might take a little bit longer, as we've hardly had the time to look at predefined context items yet (most of our users seem to start their queries from the root node, or from nodes specified in the query itself – if someone else feels addressed here, please tell us); you'll be notified, however, as soon as a handsome solution on this has been found.
Thanks, Christian