From: Dmitriy S. <sha...@gm...> - 2010-07-21 11:37:40
|
Note: There are functions like fn:string or fn:base-uri that "... In the zero-argument version of the function, $arg defaults to the context item. That is, calling fn:string() is equivalent to calling fn:string(.). ..." The question "why" didn't get answer ... -- Cheers, Dmitriy Shabanov On Wed, 2010-07-21 at 13:23 +0200, James Fuller wrote: > 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 |