Write several XML files via one XQuery
Monday, 1 March 2021 · 2 messages
BN
Brune, Nicole1 Mar 2021 13:34 #
Dear all,
please excuse me if this has been covered in the documentation and I just haven't found it. I am trying to harvest some information from XML files in a database (all XML files) and create several new XML files with the information. I am aware of the function write:file(path, data). Is it possible to write several files in one go and via one XQuery? I have tried exchanging "../test.xml" with "../test[1 to 2000].xml, ..." but, unfortunately, it did not work.
Thank you kindly in advance for your help!
Best,
Nicole
CG
Christian Grün1 Mar 2021 13:37 #
Hi Nicole,
That should certainly be possible, e.g. by using a loop:
for $doc at $p in collection('docs')
return file:write('/path/to/' || $p || '/xml', $doc)Could you forward us a little code snippet that demonstrates what you have tried so far?
Thanks in advance,
Christian
Quoted text · Nicole · 20 lines
On Mon, Mar 1, 2021 at 1:34 PM Brune, Nicole <Brune at zbmed.de> wrote: > > Dear all, > > > > please excuse me if this has been covered in the documentation and I just haven’t found it. > > I am trying to harvest some information from XML files in a database (all XML files) and create several new XML files with the information. I am aware of the function write:file(path, data). > > Is it possible to write several files in one go and via one XQuery? I have tried exchanging „../test.xml“ with „../test[1 to 2000].xml, …“ but, unfortunately, it did not work. > > > > Thank you kindly in advance for your help! > > > > Best, > Nicole
Written for BaseX 9.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery