繁体   English   中英

如何从 BaseX 控制台执行 XQuery?

[英]how to execute an XQuery from the BaseX console?

如何在独立模式下从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 工作正常

查询

路径固定:

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 确认这是一个路径问题。)

暂无
暂无

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

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