context across function calls

I refer to a previous post by Per Bothner to www-xml-query-comments:

http://lists.w3.org/Archives/Public/www-xml-query-comments/2002Apr/0023.html

I'd love some clarification on this issue.

To summarize the question, consider the following code fragment (taken
from the above post):

define function is-mid() {
   return position() == last() / 2
}

document("foo.xml")/book/chapter[is-mid()]

When is-mid() is called, and it evaluates position() and last(), do
these return values with respect to the context in the main expression?
Or does the context "reset" when you enter a function call, so that the
above would (possibly) return an error?

A *quick* scan of the use cases found none which define functions that
access an "external" context.  However, the draft standard is very
ambiguous on this point.

This is quite an important issue (in terms of its possible effect on the
current formal semantics).  It would be wonderful to get some idea as to
the current intentions of the working group, even if the issue is not
yet finalized.

Thanks,
Damien Fisher

Received on Wednesday, 14 August 2002 10:49:44 UTC