Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XQuery:计算函数的参数_Xquery - Fatal编程技术网

XQuery:计算函数的参数

XQuery:计算函数的参数,xquery,Xquery,我有一个XQuery函数 declare function local:helloWorld($param1 as xs:string, $param2 as xs:string) as element() { 现在,我想说,是否可以计算传递给我的函数的参数 declare function local:helloWorld($param1 as xs:string, $param2 as xs:string) as element() { 有可能吗 提前感谢没有计算传递给函数的参数数量

我有一个XQuery函数

declare function local:helloWorld($param1 as xs:string, $param2 as xs:string)  as element() {
现在,我想说,是否可以计算传递给我的函数的参数

declare function local:helloWorld($param1 as xs:string, $param2 as xs:string)  as element() {
有可能吗


提前感谢

没有计算传递给函数的参数数量的函数。参数的数量由函数声明固定。它不能根据输入而改变


这解释了函数。

在标准XQuery中,这是不可能的

然而,下一个Zorba发行版(2.0版)很快就会面世,它将包括一个内省库,它正是您想要的。例如,在Zorba的当前svn版本上,执行以下查询:

import module namespace sctx = "http://www.zorba-xquery.com/modules/introspection/sctx";

declare function local:helloWorld($param1 as xs:string, $param2 as xs:string)  as xs:string {
  fn:concat($param1, $param2)
};

sctx:function-arguments-count(xs:QName("local:helloWorld"))

将返回“2”(如预期)。还有一个模块可以进行反射,因此您可以完全动态地构建函数调用。但是你付出的代价当然是,这段代码将不再可移植到其他XQuery引擎。

是的,这是可能的,计数是2。这可能不是您想要的,因此有关上下文的一些信息将非常有用。