Subject:Xquery outputs XML attributes sorted by attribute name Author:Dominic Vieira Date:31 Jan 2008 01:43 PM
Is there a setting or reason when using attributes in xquery the xml output displays the attributes in ascending order?
Sample xquery code snippet;
<Test>
{
for $Record3 at $i in doc('file:///c:/userfield.xml')/Records/Record
where (($Record3/batch_number = $Record2/batch_number) and ($Record3/tran_number = $TranNo)) and ($Record3/docformat_id = $Record5/docformat_id)
return
<TtestField test6="test6" test4="test4" test7="test7"/>
}
</Test>
When the code is executed the following is output;
<Test>
<TestField test4="test4" test6="test6" test7="test7"/>
</Test>
Notice the order in which the attribute displays has changed from what is written in the code? In code it is test6, test4, test7. The output sorts the attributes; test4, test6, test7. I've hardcoded the values in the sample but using actually data "{$datafield} presents the same issue.
Subject:Xquery outputs XML attributes sorted by attribute name Author:Minollo I. Date:31 Jan 2008 01:55 PM
What XQuery processor are you using? I don't see that behavior using DataDirect XQuery, but I do see it using Saxon.
BTW, the order of attributes is completely irrelevant in the XML InfoSet... so, what you are describing is just an entirely legitimate serialization choice.
Subject:Xquery outputs XML attributes sorted by attribute name Author:Minollo I. Date:31 Jan 2008 03:33 PM
"it" being? The ordering of attributes? Not that I know of; you may want to ask saxonica dot com about Saxon.
As I said, DataDirect XQuery doesn't seem to re-order them in the cases I checked; DataDirect XQuery is bundled with all Stylus Studio Enterprise Suites.