加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 使用XQuery引用BaseX DB中的特定文档

发布时间:2020-12-16 05:36:53 所属栏目:百科 来源:网络整理
导读:如果我向BaseX DB添加两个文档,比如说normal.xml和normal2.xml,有没有办法单独引用每个文档? 我知道doc()函数,但它查看文件系统的位置,而不是数据库本身. 例如,如果我查询:doc(“normal.xml”)/ name,那么我将收到有关找不到normal.xml的错误. 我也尝试过
如果我向BaseX DB添加两个文档,比如说normal.xml和normal2.xml,有没有办法单独引用每个文档?

我知道doc()函数,但它查看文件系统的位置,而不是数据库本身.

例如,如果我查询:doc(“normal.xml”)/ name,那么我将收到有关找不到normal.xml的错误.

我也尝试过:basex:db(“my-db-name”)/ doc(“normal.xml”)/ name并收到同样的错误.

有任何想法吗?

我最后询问了 BaseX mailing list,我收到的答案如下:
for $doc in collection('test-db')
    where matches(document-uri($doc),'example.xml')
return $doc

我还询问为什么没有直接的方法来引用要在恒定时间内提取数据的文档,响应是:

This is due to the 07001. XQuery has no formal notion of files inside a database/collection (Christian might correct me if I am wrong),
so the collection() command returns any sequence of (document-)nodes for the given database.
It is up to the user to pick those nodes he wants to process.

We are currently looking for ideas on navigating collections more intuitively; something similar to
“collection(‘db/path-to/document.xml’)” that should still conform to the current W3C recommendation.
As the subsequent document-uri() usually works well enough this is not too high on our priority list.

谢谢你的帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读