[ Just a shout from the cheap seats in the gallery. In my experience, the order of attributes may have considerable esthetic value and may have impact on the acceptance of a program. The order therefore does deserve attention, in spite of its theoretical insignificance. Even more important than the order coming out of a literal constructor may be the order resulting from a dynamic constructor, that is, a sequence of attribute {...} {...}, because the developer can control that order dynamically, and all is well, provided BaseX plays along and retains the order. Yes, reordering is possible with the comma expression, but it would be nice to get away without that extra mile. ]
Am Donnerstag, 10. Februar 2022, 10:34:56 MEZ hat Christian Grün christian.gruen@gmail.com Folgendes geschrieben:
Hi Jonathan,
Is there any way for me to control the order of attributes in BaseX when I insert new attributes?
If you evaluate the following XQuery expression in BaseX …
<a b='b' c='c'/>
… you can be sure that the attributes will be placed in the original order. Please note that we cannot give a guarantee that this will stay that way forever, even though it’s unlikely to change.
If you have an existing element, you can reinsert all attributes in the order you want:
let $a := <a b='b' c='c'/> return element { node-name($a) } { $a/@*, attribute d { 'd' }, $a/node() }
How do you currently proceed?
Best, Christian