[英]Execute XQuery with BaseX
I am trying to use BaseX
to run an XQuery
with no success. 我试图使用BaseX
运行XQuery
失败。 I have tried typing commands like: 我尝试过键入以下命令:
doc("Bookstore.xml")//Bookstore
//Bookstore
XQUERY[//Bookstore]
and i am getting these error messages: 我收到这些错误消息:
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.
whenever i try to hit Execute Query . 每当我尝试点击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
. 我正在观看Stanford教程,但是那里显示的那些命令在BaseX
不起作用。
Below you can just see the file
i am trying to query for educational purposes. 在下面,您可以仅查看出于教育目的而尝试查询的file
。
<?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>
EDIT 编辑
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命令,例如在BaseX命令行客户端或GUI命令行中运行,则必须在查询前添加命令XQUERY
。 BaseX commands are separated by whitespace from their parameters, so in your case, run any of BaseX命令与参数之间用空格隔开,因此,在您的情况下,请运行以下任意命令
XQUERY //Bookstore
XQUERY doc('Bookstore.xml')//Bookstore
depending on whether the document (database) is already opened or not. 取决于文档(数据库)是否已打开。
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) 如果您使用的是BaseX GUI ,还可以直接将查询放入查询窗口,那么您根本不需要XQUERY
命令前缀,而直接使用其中之一(如上)
//Bookstore
//doc('Bookstore.xml')//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. 无论如何:您可能要改用/Bookstore
:至少在我猜对了并且您要查询根元素时,而不是在整个文档中查询所有<Bookstore/>
元素时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.