After a little more investigation of the XQuery Update standard, it looks to me like BaseX is doing this right and the standard does not allow for positioning of attribute insertions (unless there’s another approach I’ve overlooked). In case anyone else has a similar question – all insert operations involving attributes resolve to the function upd:insertAttributes which does not allow for positioning. It appears as though the modifiers “as first” and “as last” are ignored in the case of attributes.
I suppose this makes sense if the ordering of attributes in XML is unimportant and undefined. Can anyone clarify what the XML/XDM standard has to say on the topic of attribute ordering? It’s a little confusing because many XML processors attempt to present attributes with some kind of explicit ordering (as an example, see the .NET XmlAttributeCollection class which allows programmatic insertion of attributes before/after a reference attribute).
Thanks (again),
Dave
From: Dave Glick
Sent: Friday, December 02, 2011 12:37 PM
To: basex-talk@mailman.uni-konstanz.de
Subject: Insert position of attributes
How would one go about inserting an attribute at a specific position (i.e., somewhere other than at the front of the attribute list)? I would expect the following expression would do the trick: “insert node attribute aname {'avalue'} as last into //XYZ” but it still inserts the attribute at the front of the attribute list.
By looking at the code in the InsertAttribute update primitive, I can see that it’s hardcoded to insert at the front of the attribute list. Does this mean that there is no way to control attribute insertion location? Does the XQuery Update standard not allow such an update or is this a bug/oversight on the part of BaseX?
Thanks!
Dave
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk