从 BaseX GUI 直接写入文件 [英] Write directly to file from BaseX GUI
问题描述
我编写了一个 XQuery 表达式,它有大约 50MB 的大结果,需要几个小时来计算.我在 BaseX GUI 中执行它,但这有点不方便:它将结果裁剪到结果窗口,然后我必须保存它.此时,BaseX 变得无响应并可能崩溃.
I wrote an XQuery expression that has a large result of about 50MB and takes a couple of hours to compute. I execute it in the BaseX GUI, but this is a little inconvenient: it crops the result to a result window, which I then have to save. At this time, BaseX becomes unresponsive and may crash.
有没有办法直接将结果写入文件?
Is there a way to directly write the result to a file?
推荐答案
看看 BaseX' 文件模块,它提供了广泛的功能来读写文件和遍历文件系统.
Have a look at BaseX' file module, which provides broad functionality to read and write from files and traverse the file system.
对于你来说,file:write($path as xs:string, $items as item()*) as empty-sequence()
将特别有趣,它允许将元素序列写入文件.例如:
For you, file:write($path as xs:string, $items as item()*) as empty-sequence()
will be of special interest, which allows to write an element sequence to a file. For example:
file:write(
'/tmp/output.xml',
<root>{
for $i in 1 to 1000000
return <some-large-amount-of-data />
}</root>
)
如果您的输出不是格式良好的 XML,请考虑使用 file:write-binary
、file:write-text
和 file:write-text-lines
函数.
If your output isn't well-formed XML, consider the file:write-binary
, file:write-text
and file:write-text-lines
functions.
另一种选择可能是写入数据库中的文档而不是文件.db:add
和 db:create
来自 数据库模块可用于将计算结果添加到当前或新数据库中.
Yet another alternative might be writing to documents in the database instead of files. db:add
and db:create
from the database module can be used to add the computed results to the current or a new database.
这篇关于从 BaseX GUI 直接写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!