【问题标题】:how to execute an XQuery from the BaseX console?如何从 BaseX 控制台执行 XQuery?
【发布时间】:2019-01-02 15:45:39
【问题描述】:

如何在standalone 模式下从BaseX 运行XQuery

使用BaseX进行简单的读取和查询:

thufir@dur:~/basex$ 
thufir@dur:~/basex$ basex
[warning] /usr/bin/basex: Unable to locate /usr/share/java/jing.jar in /usr/share/java
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
> 
> LIST
Name  Resources  Size  Input Path                        
-------------------------------------------------------
note  1          5208  /home/thufir/basex/note.data.xml  

1 database(s).
> 
> OPEN note
Database 'note' was opened in 65.07 ms.
> 
> XQUERY db:open("note")//note
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>
Query executed in 251.29 ms.
> 
> RUN query.note.db.xq
Resource "/home/thufir/query.note.db.xq" not found.
> 
> RUN query.note.xq
Resource "/home/thufir/query.note.xq" not found.
> 
> exit
Have a nice day.
thufir@dur:~/basex$ 

查询保存为XQuery 文件:

thufir@dur:~/basex$ 
thufir@dur:~/basex$ cat query.note.db.xq 

db:open("note")//note


thufir@dur:~/basex$ 
thufir@dur:~/basex$ cat query.note.xq 
//note
thufir@dur:~/basex$ 
thufir@dur:~/basex$ pwd
/home/thufir/basex
thufir@dur:~/basex$ 

从 GUI 工作 fine

【问题讨论】:

    标签: xml xpath command-line-interface xquery basex


    【解决方案1】:

    路径固定:

    thufir@dur:~/basex$ 
    thufir@dur:~/basex$ basex
    [warning] /usr/bin/basex: Unable to locate /usr/share/java/jing.jar in /usr/share/java
    BaseX 9.0.1 [Standalone]
    Try 'help' to get more information.
    > 
    > RUN basex/query.note.db.xq
    <note>
      <to>Tove</to>
      <from>Jani</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!</body>
    </note>
    Query "query.note.db.xq" executed in 472.97 ms.
    > 
    > exit
    Enjoy life.
    thufir@dur:~/basex$ 
    

    (感谢 Christian Gruen 确认这是路径问题。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2020-02-04
      • 2021-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多