From: James F. <jam...@ex...> - 2010-07-21 11:23:25
|
noticed a few irregularities in my original posting, for the sake of clarity I will summarise: as expected, this works -------------------------------------------------------------------- declare function local:test($arg){ name($arg) }; let $a := <test><a></a><b/></test> return local:test($a) -------------------------------------------------------------------- then we have -------------------------------------------------------------------- declare function local:test(){ name() }; let $a := <test><a></a><b/></test> return $a/local:test() -------------------------------------------------------------------- which works, and I can see the sense of it, as we are using the xpath to set context, but can't find the 'words' in the specs that allow this. similarly -------------------------------------------------------------------- declare function local:test(){ name(.) }; //*/local:test() -------------------------------------------------------------------- but what is defo not conformant is something like -------------------------------------------------------------------- declare function local:test(){ //* }; local:test() -------------------------------------------------------------------- which just arbitrarily gives function access to db root context. a few thoughts as I am occupied working on other stuff at the moment but will scan the specs soon: * does an unadorned function, e.g. without being in an explicit xpath actually have a default context always supplied ? e.g. is local:test() shorthand for /./local-test() or something of the kind ? * is context passed via xpath e.g. //$arg/local:test() or //*/local:test() ok, seems to invalidate what is said in the XQuery section 3.1.5 * as a lot of existing xquery code (mine included) wil break with this change, as suggested we need both an exist option and a util function to switch behaviors and have default configured as to how things work now. For those who want more conformant behavior or more security on the context that a function is allowed can switch this default configuration thx, J |