Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort all attributes of XML in SQL query using XQuery

How can get the XML with sorted attributes using XQuery in SQL?

for example for this XML:

<root><book b='' c='' a=''/></root>

must return:

<root><book a='' b='' c=''/></root>
like image 530
ARZ Avatar asked Oct 10 '22 03:10

ARZ


1 Answers

Attributes are unordered in XML, so the document is considered the same whichever order the attributes are printed out in. XQuery certainly has no way to change the order of attributes, and I doubt SQL XML does either.

like image 157
John Snelson Avatar answered Oct 18 '22 15:10

John Snelson