[xquery-talk] using a context node in a for loop
David Carlisle
davidc at nag.co.uk
Tue Oct 17 17:05:03 PDT 2006
> Should the function below work?
no:-)
a function does not automatically pass the current context,
. is undefined in a function body, so you can't use relative paths like
'@id and @db-ref
Built in functions can take an empty param list () and automatically work on
the current node, but user defined ones can not do that: you have to call
it as
local:display-user-groups(.)
^
and define it as
declare function local:display-user-groups($here as element()) as
element()* {
...
then use $here/@id $here/@db-ref
or give yourself a current node again by
$here/
(for $user-group ....
in which case you can use {@id} as you have now.
(The same is true for xslt2 functions by the way)
David
More information about the talk
mailing list