So it turns out what works is for $stable in map:keys($composedMap) return insert node attribute {'id'} {$composedMap($stable)?composed} into db:get-id('ID-DB',$stable) The same pattern does not work in update; I do not understand why the above expression is happening to database nodes and the original attempt does not. If anyone is able to explain the distinction I am very curious as to whether I would be able to muster enough neurons to comprehend it. On Tue, Feb 17, 2026, at 18:27, Graydon Saunders via BaseX-Talk wrote:
Hello --
Using db:node-id() is an order of magnitude faster than using generate-id() to relate various nodes to their ancestors when constructing a composite id. This works great.
Now I have a map (the keys are the value returned by db:node-id() for specific elements) and I want to update either a document or the db to have the new, calculated values as id attribute values.
I expected that I could use
for $thisDoc in db:get('ID-DB') ...calculate some stuff... ... $hasIDKey is the map:keys() of the map of calculated values...
return $thisDoc update {(//*[db:node-id(.) = $hasIDKey]) ! (insert node attribute { 'id' } { $composedMap(./db:node-id(.))?composed } into .)}
This pattern worked with generated-id() values; with db:node-id() the error I get is:
[db:node] No database node: <publication.../>.
(Publication is the expected document element.)
db:node-id() worked in a function in a library module when $thisDoc was a parameter, so I'm at a bit of a loss; I would have expected that db:node-id() is the stable identifier and could work with updating expressions but perhaps that was optimism.
Is there an appropriate way to relate a db:node-id() value to an element in an updating expression?
Thanks! Graydon