简体   繁体   English

BaseX:更新不会被回写

[英]BaseX: Updates are not written back

I am trying to run the following query in BaseX, 我正在尝试在BaseX中运行以下查询,

let $c := doc('t.xq')//entry return (replace value of node $c/author with 'BaseX' )

The input file t.xq is 输入文件t.xq

<entry>
    <title>Transform expression example</title>
    <author>BaseX Team</author>
  </entry>

I expect it to return the modified data, but it executes and return nothing. 我希望它返回修改后的数据,但是它执行并且什么也不返回。 it says Updates are not written back 它说Updates are not written back

How can I see the modified entry ? 如何查看修改后的entry which commands return the altered data? 哪些命令返回更改的数据?

Cited from http://docs.basex.org/wiki/XQuery_Update : http://docs.basex.org/wiki/XQuery_Update引用:

In BaseX, all updates are performed on database nodes or in main memory. 在BaseX中,所有更新都在数据库节点或主内存中执行。 By default, update operations do not affect the original input file (the info string "Updates are not written back" appears in the query info to indicate this). 默认情况下,更新操作不会影响原始输入文件(查询信息中显示信息字符串“ Updates not not backed”(更新未写回)以表明这一点)。 The following solutions exist to write XML documents and binary resources to disk: 存在以下解决方案可将XML文档和二进制资源写入磁盘:

  • Updates on main-memory instances of files that have been retrieved via fn:doc or fn:collection will be propagated back to disk when the WRITEBACK option is turned on. 当打开WRITEBACK选项时,通过fn:doc或fn:collection检索的文件的主内存实例更新将传播回磁盘。 This option can also be activated on command line via -u. 也可以通过-u在命令行上激活此选项。 Make sure you back up the original documents before running your queries. 在运行查询之前,请确保备份原始文档。
  • Functions like fn:put or file:write can be used to write single XML documents to disk. fn:put或file:write之类的功能可用于将单个XML文档写入磁盘。 With file:write-binary, you can write binary resources. 使用file:write-binary,可以写入二进制资源。
  • The EXPORT command can be used write all resources of a databases to disk. 可以使用EXPORT命令将数据库的所有资源写入磁盘。

However, if you only need to get the output of an update command you can copy it to a variable (in memory) and transform this variable as follows: 但是,如果只需要获取更新命令的输出,则可以将其复制到变量(在内存中)并按以下方式转换此变量:

copy $c := doc('t.xq')//entry
modify (
  replace value of node $c/author with 'BaseX'
)
return $c

You can also use update which is a convenience operator for writing simple transform expressions. 您还可以使用update ,它是编写简单转换表达式的便捷运算符。

doc('t.xq')//entry update replace value of node ./author with 'BaseX'

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

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