xquery版本“1.0”;
将函数con($ s1 as xs:anyAtomicType,$ s2 as xs:anyAtomicType)声明为xs:string
{
return concat($ s1,$ s2)
};
将变量$ str1声明为xs:string:=“samah”; 将变量$ str2声明为xs:string:=“sama”; 声明变量$ comstring:= con($ str1,$ str2); {$ comstring}
答案 0 :(得分:1)
这也有效:
xquery version "1.0";
declare namespace local = "local";
declare variable $str1 as xs:string:="samah";
declare variable $str2 as xs:string:="sama";
declare variable $comstring := local:con($str1 ,$str2 );
declare function local:con($s1 as xs:anyAtomicType, $s2 as xs:anyAtomicType) as xs:string
{
concat($s1, $s2 )
};
$comstring
答案 1 :(得分:0)
您的查询语法错误。 return
仅在for
,let
,where
或order by
条款后生效。删除单词return
。
其次,{
和}
仅在节点内容中有效,因此应删除。
最后,函数和变量不能在XQuery函数名称空间中声明,因此这些函数和变量必须在另一个名称空间中声明。
编译错误当然应该告诉你这一切吗?
declare namespace test = "http://www.example.org/test";
declare function test:con($s1 as xs:anyAtomicType, $s2 as xs:anyAtomicType) as xs:string
{
concat($s1, $s2)
};
declare variable $test:str1 as xs:string:="samah";
declare variable $test:str2 as xs:string:="sama";
declare variable $test:comstring:=test:con($test:str1 ,$test:str2 );
$test:comstring