如何将上下文设置为特定数据库,然后在FLOWR中引用该数据库?
PS C:\Users\thufir\Desktop\basex>
PS C:\Users\thufir\Desktop\basex>
PS C:\Users\thufir\Desktop\basex> basex .\openDB.xq
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
PS C:\Users\thufir\Desktop\basex>
PS C:\Users\thufir\Desktop\basex> type .\openDB.xq
let $db := db:open("books")
for $item in $db
return $item/bookstore/book[3]
PS C:\Users\thufir\Desktop\basex>
PS C:\Users\thufir\Desktop\basex> basex db.xq
Stopped at C:/Users/thufir/Desktop/basex/db.xq, 1/21:
[XPST0003] Expecting ':=', found 's'.
PS C:\Users\thufir\Desktop\basex>
PS C:\Users\thufir\Desktop\basex> type .\db.xq
declare context items := db:open("books")
for $ctx in .
return $ctx
PS C:\Users\thufir\Desktop\basex>
PS C:\Users\thufir\Desktop\basex>
另请参阅:
how to return the third book from this bookstore using FLOWR in XQuery?
我想这样指定数据库:
how to specify a BaseX database from a FLOWR xquery?
,但在XQuery本身的上下文中明确。