BaseX:更新不回写
BaseX: Updates are not written back
我正在尝试 运行 BaseX 中的以下查询,
let $c := doc('t.xq')//entry return (replace value of node $c/author with 'BaseX' )
输入文件t.xq
是
<entry>
<title>Transform expression example</title>
<author>BaseX Team</author>
</entry>
我希望它 return 修改后的数据,但它执行了 return 什么也没有。
它说 Updates are not written back
如何查看修改后的entry
?哪些命令 return 更改的数据?
引自http://docs.basex.org/wiki/XQuery_Update:
In BaseX, all updates are performed on database nodes or in main
memory. 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). The following solutions exist to write
XML documents and binary resources to disk:
- 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. This option can also be
activated on command line via -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. With file:write-binary, you can write binary
resources.
- The EXPORT command can be used write all resources of a databases to disk.
但是,如果您只需要获取更新命令的输出,您可以将其复制到一个变量(在内存中)并按如下方式转换此变量:
copy $c := doc('t.xq')//entry
modify (
replace value of node $c/author with 'BaseX'
)
return $c
您还可以使用 update
,它是编写简单转换表达式的便捷运算符。
doc('t.xq')//entry update replace value of node ./author with 'BaseX'
我正在尝试 运行 BaseX 中的以下查询,
let $c := doc('t.xq')//entry return (replace value of node $c/author with 'BaseX' )
输入文件t.xq
是
<entry>
<title>Transform expression example</title>
<author>BaseX Team</author>
</entry>
我希望它 return 修改后的数据,但它执行了 return 什么也没有。
它说 Updates are not written back
如何查看修改后的entry
?哪些命令 return 更改的数据?
引自http://docs.basex.org/wiki/XQuery_Update:
In BaseX, all updates are performed on database nodes or in main memory. 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). The following solutions exist to write XML documents and binary resources to disk:
- 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. This option can also be activated on command line via -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. With file:write-binary, you can write binary resources.
- The EXPORT command can be used write all resources of a databases to disk.
但是,如果您只需要获取更新命令的输出,您可以将其复制到一个变量(在内存中)并按如下方式转换此变量:
copy $c := doc('t.xq')//entry
modify (
replace value of node $c/author with 'BaseX'
)
return $c
您还可以使用 update
,它是编写简单转换表达式的便捷运算符。
doc('t.xq')//entry update replace value of node ./author with 'BaseX'