Hi Dimitar, Since collections are sequences, can I use [1] or [last()] to specify which one to delete? As per my requirement, I need to be able to delete older resources after some processing (data consolidation).
Thanks for your help.
Best regards, Anupam
Am Freitag, 1. Juni 2012, 10:53:30 schrieb Anupam Bakshi:
Hi Dimitar, Since collections are sequences, can I use [1] or [last()] to specify which one to delete? As per my requirement, I need to be able to delete older resources after some processing (data consolidation).
Thanks for your help.
Best regards, Anupam
Hi Anupam,
sorry, but as far as I can tell, you can't do that. I would recommend deleting the existing document before you add the new one.
If you remove this line [1] from BaseX source code, then you could use something like this:
delete node collection('sample1.xml')[1]
However, I'm not sure what side effects that would have. Maybe someone else on the ML can tell better.
hth, Dimitar
PS: you are not hogging the list - it's always nice to have some user feedback :)
[1]https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/query/u...
Hi Anupam,
as Dimitar outlined (thanks), it's not possible to delete a single one of several documents with the same name. As the XQuery Update Facility does not support the removal of document nodes [1], you need to use db:delete(), which selects all documents that start with the specified file path... or db:replace() [2], which could be the best fit for your requirements, as it deletes existing documents before adding new ones.
Christian
[1] http://www.w3.org/TR/xquery-update-10/#id-delete [2] http://docs.basex.org/wiki/Database_Module#db:replace ________________________________________
On Fri, Jun 1, 2012 at 9:15 PM, Dimitar Popov Dimitar.Popov@uni-konstanz.de wrote:
Am Freitag, 1. Juni 2012, 10:53:30 schrieb Anupam Bakshi:
Hi Dimitar, Since collections are sequences, can I use [1] or [last()] to specify which one to delete? As per my requirement, I need to be able to delete older resources after some processing (data consolidation).
Thanks for your help.
Best regards, Anupam
Hi Anupam,
sorry, but as far as I can tell, you can't do that. I would recommend deleting the existing document before you add the new one.
If you remove this line [1] from BaseX source code, then you could use something like this:
delete node collection('sample1.xml')[1]
However, I'm not sure what side effects that would have. Maybe someone else on the ML can tell better.
hth, Dimitar
PS: you are not hogging the list - it's always nice to have some user feedback :)
[1]https://github.com/BaseXdb/basex/blob/master/src/main/java/org/basex/query/u... _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hello Christian, Dimitar,
Thanks for your replies and helpful suggestions. (BTW, the collections('path')[1] did not work).
The workarounds are not ideal because what I was hoping to implement was a FIFO (first in first out) flow, where documents come in at a different pace than the pace at which they are consumed. The two operations are asynchronous.
I'll try and use the workarounds you suggested. Although it would have been nice to have that feature ( be able to specify the resource that has to be deleted on the same path).
Best regards, Anupam
Hi Anupam,
is it possible to you to rename the documents before adding them? I would propose to suffix the current timestamp and/or look into the system if another resource with the same name already exists and add some suffix. You would have unique names, can query them (don't know if there's a more elegant way then list all resources and filter them using regex or whatever, probably the list could help with this) and FIFO wouldn't be any problem any more.
Kind regards, Jens
basex-talk@mailman.uni-konstanz.de