generate-id() is not unique in loop
Hello, this seems to be critical bug in [BaseX7.8.2]. The following code let $a := <element></element> for $i in (1 to 5) return copy $b := $a modify ( insert node attribute id { generate-id() } into $b ) return $b will return elements with the same IDs, i.e.: <element id="id31442"/> <element id="id31442"/> <element id="id31442"/> <element id="id31442"/> <element id="id31442"/>
Hello Sergey, Based on the spec (http://www.w3.org/TR/xpath-functions-30/#func-generate-id) generate-id() uses the context-item if no argument is present. As the context item is the same in each of your calls, it will return the same id. Using generate-id($b) should be enough to generate distinct ids. Cheers, Dirk On 10/07/14 02:56, Sergey Alekhin wrote:
Hello, this seems to be critical bug in [BaseX7.8.2]. The following code
let $a := <element></element>
for $i in (1 to 5)
return copy $b := $a modify (
insert node attribute id { generate-id() } into $b
)
return $b
will return elements with the same IDs, i.e.:
<element id="id31442"/>
<element id="id31442"/>
<element id="id31442"/>
<element id="id31442"/>
<element id="id31442"/>
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
participants (2)
-
Dirk Kirsten -
Sergey Alekhin