Hello again,
You guys do such a great job of answering and responding to questions and concerns on this board, thanks again for that Christian. This next one might be a case of misunderstanding the standard on my part, but I'm seeing some odd things with XQuery when using a different initial context than the document root. Take the following XML:
<test> <a> <aa/> <ab> <aba/> <abb/> <abc/> </ab> <ac/> </a> <b> <ba/> <bb> <bba/> <bbb/> <bbc/> </bb> <bc/> </b> </test>
Here is the result of several different XQuery commands with different initial contexts (I've loaded the document into the BaseX GUI and am setting initial context by double-clicking the element in the grid view)...
Query: . Context: document, Result: The entire document (as expected) Context: <b>, Result: The <b> element and all its content (as expected)
Query: let $v := . return $v Context: document, Result: The entire document (as expected) Context <b>, Result: The entire document (was expecting the <b> element and all its content!)
Query: .//ab Context: document, Result: Result: The <ab> element and its content (as expected) Context <b>, Result: Nothing (as expected)
Query: let $v := //ab return $v Context: document, Result: The <ab> element and its content (as expected) Context: <b>, Result: The <ab> element and its content (as expected)
Query: let $v := .//ab return $v Context: document, Result: The <ab> element and its content (as expected) Context: <b>, Result: The <ab> element and its content (was expecting nothing!)
As you can see, it seems to behave counter to expectations when the initial context is not the document and I use the initial context in the FLOWR expression. I attempted to test in other tools, but it appears that setting the initial context for an XQuery expression is actually a difficult feature to find. It's not a totally academic question, though - the system we're building uses initial contexts pretty extensively.
I know that context is not maintained in XQuery, but can the initial context not be used in variable assignment or other components of a FLOWR expression?
Thanks,
Dave