[英]How to declare a function in Xbase
嗨,這可能是一個奇怪的問題,但我想知道如何在 Xbase 中聲明 function。
有人告訴我這是如何:
declare function prefix:name($parameter as DataType)
as returnDataType {
..code..
};
我這樣做了:
declare function local:test($i as xs:integer?)
as xs:integer
{
return $i
};
但它一直說我有語法問題
期待表達。
我找到了這個問題的答案,問題是當你在 Xbase 中聲明一個 function 時,你必須在聲明之后調用它,如下所示:
//declare your function
<test>{local:test("Example")}</test>
否則,它會將其視為語法問題。
你的 function 應該是
declare function local:test($i as xs:integer?)
as xs:integer
{
$i
};
在 XQuery 中, return
關鍵字僅用於 FLWOR 表達式。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.