繁体   English   中英

BaseX XQuery没有定义上下文项来评估'root()'

[英]BaseX XQuery No context item defined to evaluate 'root()'

我正在BaseX上尝试此XQuery

xquery //Bookstore/Book/Title

尽管在2:01教程中它对我有用 ,但会引发此错误:

Error:
Stopped at ., 1/2:
[XPDY0002] No context item defined to evaluate 'root()'.
Compiling:
- simplifying descendant-or-self step(s)
Query:
//Bookstore/Book/Title
Optimized Query:
root()/descendant::Bookstore/Book/Title
Query plan:
<QueryPlan>
  <CachedPath>
    <Root/>
    <IterStep axis="descendant" test="Bookstore"/>
    <IterStep axis="child" test="Book"/>
    <IterStep axis="child" test="Title"/>
  </CachedPath>
</QueryPlan>

我已经上网搜索了,但我真的不知道该怎么办。 为什么会发生这种情况,因为我在命令中有root element ,即Bookstore 我正在尝试查询此:

<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">
      <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>
      <Remark>
      Buy this book bundled with "A First Course" - a great deal!</Remark>
   </Book>
   <Book ISBN = "ISBN-0-11-222222-3" Price="50">
      <Title>Jennifer's Economical Database Hints</Title>
      <Authors>
         <Author>
            <First_Name>Jennifer</First_Name>
            <Last_Name>Widom</Last_Name>
         </Author>
      </Authors>
   </Book>
   <Magazine Month="January" Year="2009">
       <Title>National Geographic</Title>
   </Magazine>
   <Magazine Month="February" Year="2009">
       <Title>National Geographic</Title>
   </Magazine>
   <Magazine Month="February" Year="2009">
       <Title>Newsweek</Title>
   </Magazine>
</Bookstore>

似乎您没有打开文档(数据库),因此未定义文档根root() 有关创建数据库BaseX文档中

  • 控制台: CREATE DB db /path/to/resources将初始文档添加到数据库
  • GUI:转到数据库→新建,按浏览以选择一个初始文件或目录,然后按确定

创建数据库后,将自动打开该数据库,否则请使用控制台命令OPEN [db]或在GUI数据库→“打开并管理”中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM