使用 XQuery 引用 BaseX DB 中的特定文档
如果我向 BaseX DB 添加两个文档,例如 normal.xml
和 normal2.xml
,是否有一种方法可以单独引用每个文档?
我知道 doc() 函数,但它会在文件系统中查找它们的位置,而不是在数据库本身中。
例如,如果我使用以下查询:doc("normal.xml")/name
,那么我将收到有关未找到normal.xml
的错误。
我也尝试过: basex:db("my-db-name")/doc("normal.xml")/name
并收到相同的错误。
有什么想法吗?
If I add two documents to a BaseX DB, let's say normal.xml
and normal2.xml
, is there a way to refer to each one individually?
I know about the doc()
function, but it looks at the filesystem for their location, rather than in the database itself.
For instance, if I query with this: doc("normal.xml")/name
, then I will get an error about normal.xml
not being found.
I also tried: basex:db("my-db-name")/doc("normal.xml")/name
and received the same error.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最终在 BaseX 邮件列表上询问我收到的答案如下:
我还询问了为什么没有直接的方法来引用人们想要在恒定时间内提取数据的文档,得到的答复是:
不过还是谢谢你的帮助。
I ended up asking on the BaseX mailing list and the answer I received is as follows:
I also inquired as to why there was no direct way to reference the document one would want to extract data from in constant time, and the response was:
Thanks for the help though.
以下查询可能对您有帮助:
The following query might help you:
假设您知道,
doc()
函数就是您所需要的。假设您已经创建并打开了名为“mydb”的数据库,如果您使用以下命令添加文档:您始终可以使用以下命令打开以下文档:
ADD TO 将忽略您为其指定的文件名并使用您在URI。但请注意:运行该命令时,无法保证“your_name”的唯一性。如果它不是唯一的,(doc) 函数将抛出一个 BaseX 错误(不是 XQuery 标准的一部分),表明它匹配多个文档。
The
doc()
function is all you need assuming you know. Assuming you have created and opened a database named 'mydb,' if you add a document with the following command:You can always open the following document using:
ADD TO will ignore the file name you gave it and use the name you specified in the URI. Be warned though: there is no guarantee of uniqueness of 'your_name' when you run that command. And if it's not unique, the (doc) function will throw a BaseX error (not part of XQuery standard) saying it matches more than one document.