Hi Graydon - I'm curious to hear other thoughts on this, I recall a struggle with something similar (wanting persistent access to node identifiers), and I wound up with a kludge that leveraged `db:node-pre()` and `db:get-id()`. I *think* trying to make in-database identifiers persistent would be circular, ie you write the file to the database, generate the node-id/node-pre values, but exposing those values in the document would change the document, and.... I'm not sure if I'm thinking about it clearly or not. Also, now that I think about it, I'm not entirely sure if the db:node-id/db:get-id is persistent - the db:node-pre/db:get-pre will change if documents are updated/deleted.
What about a pre-processing step that ran an identity transform that added a `generate-id()`'d identifier to your chosen elements, then adding the document to your db? I don't think I answered your question, but I'm curious to learn more. Best, Bridger PS after adding a document to the database, you could run a process that updated a map in the `store` main memory using the db:node-id/db:get-id functions, then you could refer to that? PPS Excuse any misunderstanding of the problem. I'm insufficiently caffeinated today. On Mon, Feb 9, 2026 at 10:48 AM Graydon Saunders via BaseX-Talk <[email protected]> wrote: > > Hi! > > I'm loading a document with doc() and doing a bunch of stuff to regenerate id > attribute values; I'm using generated ids (from generate-id()) as map keys so > I can generate the local, this-element id component and then put them all > together from the list of ancestor ids. That works. > > What doesn't work is trying to use those ids to identify the element which > should get this newly constructed id value; calling generate-id() again on > the same document doesn't give the same answers. (which is to be expected, at > least as I understand how generate-id() is defined.) > > I have this vague memory that there's a BaseX function that will produce a > stable id, but can't remember what it is called. (Or if it will work when I > get the document with doc().) > > Is there such a thing, and if so, what module should I be looking in? > > Thanks! > Graydon

