使用 BaseX 执行 XQuery [英] Execute XQuery with BaseX

查看:24
本文介绍了使用 BaseX 执行 XQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 BaseX 来运行 XQuery 但没有成功.我试过输入如下命令:

I am trying to use BaseX to run an XQuery with no success. I have tried typing commands like:

doc("Bookstore.xml")//Bookstore
//Bookstore
XQUERY[//Bookstore]

我收到这些错误消息:

Stopped at C:/tools/libxml/file, 1/32:
Unknown command: doc("Bookstore.xml")//Bookstore. Try HELP.

Stopped at C:/tools/libxml/file, 1/12:
Unknown command: //Bookstore. Try HELP.

Stopped at C:/tools/libxml/file, 1/20:
Unknown command: XQUERY[//Bookstore]. Try HELP.

每当我尝试点击执行查询.我怎样才能使它真正起作用?我正在观看 Stanford 教程,但在那里显示的那些命令在 <代码>BaseX.

whenever i try to hit Execute Query. How can i make this actually work? I am watching the Stanford tutorials but those commands that are showing there do not work on BaseX.

您可以在下方看到我出于教育目的而尝试查询的 file.

Below you can just see the file i am trying to query for educational purposes.

<?xml version="1.0" ?>
<!--Bookstore with no DTD-->

<Bookstore>
   <Book ISBN="ISBN-0-13-713526-2" Price="85" Edition="3rd">
      <Title>A First Course in Database Systems</Title>
      <Authors>
         <Author>
            <First_Name>Jeffrey</First_Name>
            <Last_Name>Ullman</Last_Name>
         </Author>
         <Author>
            <First_Name>Jennifer</First_Name>
            <Last_Name>Widom</Last_Name>
         </Author>
      </Authors>
   </Book>
   <Book ISBN="ISBN-0-13-815504-6" Price="100">
      <Remark>
      Buy this book bundled with "A First Course" - a great deal!
      </Remark>
      <Title>Database Systems: The Complete Book</Title>
      <Authors>
         <Author>
            <First_Name>Hector</First_Name>
            <Last_Name>Garcia-Molina</Last_Name>
         </Author>
         <Author>
            <First_Name>Jeffrey</First_Name>
            <Last_Name>Ullman</Last_Name>
         </Author>
         <Author>
            <First_Name>Jennifer</First_Name>
            <Last_Name>Widom</Last_Name>
         </Author>
      </Authors>
   </Book>
</Bookstore>

编辑

推荐答案

如果您正在运行 BaseX 命令,例如在 BaseX 命令行客户端 或 GUI 命令输入行中,您必须使用命令 XQUERY 为查询添加前缀.BaseX 命令与其参数之间用空格分隔,因此在您的情况下,请运行任何

If you're running BaseX commands, for example in the BaseX command line client or the GUI command input line, you have to prefix the query with the command XQUERY. BaseX commands are separated by whitespace from their parameters, so in your case, run any of

XQUERY //Bookstore
XQUERY doc('Bookstore.xml')//Bookstore

取决于文档(数据库)是否已经打开.

depending on whether the document (database) is already opened or not.

如果您使用的是BaseX GUI,您也可以直接将查询放入查询窗口中,那么您根本不需要XQUERY 命令前缀和直接其中之一(如上)

If you're using the BaseX GUI, you can also directly put the query into the query window, then you don't need the XQUERY command prefix at all and directly one of those (like above)

//Bookstore
//doc('Bookstore.xml')//Bookstore

无论如何:您可能想要使用 /Bookstore 代替:至少如果我猜对了并且您想查询根元素,而不是所有 <Bookstore/> 整个文档中的元素.

Anyway: You'll probably want to use /Bookstore instead: at least if I'm guessing correctly and you want to query the root element, and not all <Bookstore/> elements in the whole document.

这篇关于使用 BaseX 执行 XQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆