这两天碰到一个问题。关于XQuery中变量的作用域问题。
define function getResult() as node{
let $k:=$g
return $k
}
let $g:=(1,2)
rturn getResult()
$g在函数getResult中到底是否有效呢?
规范上好像也没明确说明。还是我没看明白?
[2005年11月29日]
define function getResult() as node{
let $k:=$g
return $k
}
let $g:=(1,2)
rturn getResult()
$g在函数getResult中到底是否有效呢?
规范上好像也没明确说明。还是我没看明白?
[2005年11月29日]
The
static context for a function body includes all functions that are declared or imported anywhere in the
Prolog, but it includes only those variables and namespaces that are declared or imported earlier in the Prolog than the function that is being defined.
这句应该说明上面的$g不应该是全局的。
博客主要讨论了XQuery中变量的作用域问题,给出示例代码,提出变量$g在函数getResult中是否有效的疑问,规范未明确说明,引用资料表明函数体静态上下文包含的变量和命名空间有声明先后限制,$g不应是全局的。

被折叠的 条评论
为什么被折叠?



