Write directly to file from BaseX GUI

北城余情 提交于 2020-08-04 17:15:02

问题


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?


回答1:


Have a look at BaseX' file module, which provides broad functionality to read and write from files and traverse the file system.

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>
)

If your output isn't well-formed XML, consider the file:write-binary, file:write-text and file:write-text-lines functions.

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.



来源:https://stackoverflow.com/questions/36067688/write-directly-to-file-from-basex-gui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!