XQuery - index-of 函式
index-of 函式用於跟蹤給定序列中的項。它返回整數以指示給定序列中的項的可用性。
語法
index-of($seq as anyAtomicType()*, $target as anyAtomicType())
輸入引數
$seq − 提供的序列。序列可以包含 0 個或更多項。
$target − 待返回其索引的項。
示例
XQuery 表示式
let $items := (1,2,3,4,5,6)
let $indexOf := index-of($items,4)
return
<result>
<indexof>{$indexOf}</indexof>
</result>
輸出
<result> return <indexof>4</indexof> </result>
驗證結果
為了測試上述功能,請用上面的 XQuery 表示式替換 books.xqy 的內容(在 環境設定 章節中提到),並執行 XQueryTester java 程式來驗證結果。
列印xquery_sequence_functions.htm
廣告