Hello and happy Friday --
I'm using BaseX 11.9.
I have a processing chain of queries that takes some XHTML documents and loads them into a DB. Another query reads that DB, merges the documents, and writes the merged version to disk.
From the disk copy, I create a DB of the merged content, and run another query to update that. (Changing the image references.)
I then I use another query to write the updated DB back out to disk.
If I create the DB of the merged content with the BaseX GUI "new database" dialog, everything works.
If I create the DB of the merged content using
db:create('mergedChapters', file:children($mergedDir), (), map { 'ftindex': true(), 'casesens': true(), 'createfilter': '*.html' })
I get a database and I can use db:get() to query it; for example,
db:get('mergedChapters')//*:img
from a GUI editor window gives me the expected result. (I also get the expected "you can't do that" error if I make the DB the context DB and attempt to run the "load the merged version" query again.)
When I try to run the "update the image references" query (also from a GUI editor window, and also using db:get() to access the DB) after creating the mergedChapters dB from XQuery, it does NOT work. So far as I can tell, it doesn't alter the DB at all.
I'm very sure I'm using the same database name; it's been copied out of the update-the-image-references query. I don't see an option to make the db changeable in the db:create() options.
Any suggestions?
Thanks! Graydon
Hi Graydon,
Could you provide us with a little step-by-step example to reproduce your scenario?
Thanks in advance, Christian
Graydon Saunders graydonish@fastmail.com schrieb am Fr., 23. Mai 2025, 16:36:
Hello and happy Friday --
I'm using BaseX 11.9.
I have a processing chain of queries that takes some XHTML documents and loads them into a DB. Another query reads that DB, merges the documents, and writes the merged version to disk.
From the disk copy, I create a DB of the merged content, and run another query to update that. (Changing the image references.)
I then I use another query to write the updated DB back out to disk.
If I create the DB of the merged content with the BaseX GUI "new database" dialog, everything works.
If I create the DB of the merged content using
db:create('mergedChapters', file:children($mergedDir), (), map { 'ftindex': true(), 'casesens': true(), 'createfilter': '*.html' })
I get a database and I can use db:get() to query it; for example,
db:get('mergedChapters')//*:img
from a GUI editor window gives me the expected result. (I also get the expected "you can't do that" error if I make the DB the context DB and attempt to run the "load the merged version" query again.)
When I try to run the "update the image references" query (also from a GUI editor window, and also using db:get() to access the DB) after creating the mergedChapters dB from XQuery, it does NOT work. So far as I can tell, it doesn't alter the DB at all.
I'm very sure I'm using the same database name; it's been copied out of the update-the-image-references query. I don't see an option to make the db changeable in the db:create() options.
Any suggestions?
Thanks! Graydon
Hi Christian --
My employer considers the content in the example confidential, so I'd rather not put it on the mailing list. Is there an address where I can send it?
Thanks! Graydon
On Fri, May 23, 2025, at 10:56, Christian Grün wrote:
Hi Graydon,
Could you provide us with a little step-by-step example to reproduce your scenario?
Thanks in advance, Christian
Graydon Saunders graydonish@fastmail.com schrieb am Fr., 23. Mai 2025, 16:36:
__ Hello and happy Friday --
I'm using BaseX 11.9.
I have a processing chain of queries that takes some XHTML documents and loads them into a DB. Another query reads that DB, merges the documents, and writes the merged version to disk.
From the disk copy, I create a DB of the merged content, and run another query to update that. (Changing the image references.)
I then I use another query to write the updated DB back out to disk.
If I create the DB of the merged content with the BaseX GUI "new database" dialog, everything works.
If I create the DB of the merged content using
db:create('mergedChapters', file:children($mergedDir), (), map { 'ftindex': true(), 'casesens': true(), 'createfilter': '*.html' })
I get a database and I can use db:get() to query it; for example,
db:get('mergedChapters')//*:img
from a GUI editor window gives me the expected result. (I also get the expected "you can't do that" error if I make the DB the context DB and attempt to run the "load the merged version" query again.)
When I try to run the "update the image references" query (also from a GUI editor window, and also using db:get() to access the DB) after creating the mergedChapters dB from XQuery, it does NOT work. So far as I can tell, it doesn't alter the DB at all.
I'm very sure I'm using the same database name; it's been copied out of the update-the-image-references query. I don't see an option to make the db changeable in the db:create() options.
Any suggestions?
Thanks! Graydon
Hi Graydon,
In the GUI have you tried running the command SET WRITEBACK=true in the command field? In my experience this is needed for XQuery Update expressions to persist.
See https://docs.basex.org/12/Updates#effects.
Best, Joe
Sent from my iPhone
On Sat, May 24, 2025 at 2:04 PM Graydon Saunders graydonish@fastmail.com wrote:
Hi Christian --
My employer considers the content in the example confidential, so I'd rather not put it on the mailing list. Is there an address where I can send it?
Thanks! Graydon
On Fri, May 23, 2025, at 10:56, Christian Grün wrote:
Hi Graydon,
Could you provide us with a little step-by-step example to reproduce your scenario?
Thanks in advance, Christian
Graydon Saunders graydonish@fastmail.com schrieb am Fr., 23. Mai 2025, 16:36:
Hello and happy Friday --
I'm using BaseX 11.9.
I have a processing chain of queries that takes some XHTML documents and loads them into a DB. Another query reads that DB, merges the documents, and writes the merged version to disk.
From the disk copy, I create a DB of the merged content, and run another query to update that. (Changing the image references.)
I then I use another query to write the updated DB back out to disk.
If I create the DB of the merged content with the BaseX GUI "new database" dialog, everything works.
If I create the DB of the merged content using
db:create('mergedChapters', file:children($mergedDir), (), map { 'ftindex': true(), 'casesens': true(), 'createfilter': '*.html' })
I get a database and I can use db:get() to query it; for example,
db:get('mergedChapters')//*:img
from a GUI editor window gives me the expected result. (I also get the expected "you can't do that" error if I make the DB the context DB and attempt to run the "load the merged version" query again.)
When I try to run the "update the image references" query (also from a GUI editor window, and also using db:get() to access the DB) after creating the mergedChapters dB from XQuery, it does NOT work. So far as I can tell, it doesn't alter the DB at all.
I'm very sure I'm using the same database name; it's been copied out of the update-the-image-references query. I don't see an option to make the db changeable in the db:create() options.
Any suggestions?
Thanks! Graydon
On Sun, May 25, 2025 at 04:41:37PM -0400, Joe Wicentowski scripsit:
Hi Graydon,
Hello!
In the GUI have you tried running the command SET WRITEBACK=true in the command field? In my experience this is needed for XQuery Update expressions to persist.
In this particular case, I'm writing the DB back out to disk explicitly using db:export(), and haven't had issues with persistence. (If I query the DB after the updating expression it sure looks like the change is really there, and I wouldn't want any automatic updates to the original file version during the process I'm trying to implement.)
The problem was me partaking of the cabbage-nature, rather than anything amiss with BaseX; the updating expression didn't specify the DB as part of specifying the node, so it worked when the intended DB was the context DB and didn't throw an error where some other DB was the context DB because a previous step in the process had set a context DB. And I was rather too focused on what I thought was happening to notice the "previous step has set a context DB" part.
Having boiled the test case down far enough and trying it with a freshly started instance of the BaseX GUI made this obvious when an error got thrown about the context item. And then it's just a matter of sticking a reference to the DB at the start of the XPath for the node in the updating expression and everything works as intended.
I haven't found a mechanism to set or unset the context DB; I'd really like one for writing queries with updating expressions particularly, just so I can try to code around this kind of error.
-- Graydon
-- Graydon Saunders | graydonish@fastmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")
basex-talk@mailman.uni-konstanz.de