XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Dominic VieiraSubject: 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.

Thanks.

Postnext
Minollo I.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.

Postnext
Dominic VieiraSubject: Xquery outputs XML attributes sorted by attribute name
Author: Dominic Vieira
Date: 31 Jan 2008 03:27 PM
I've tried using the built-in and saxon processor. Is there a way to turn it off?

Posttop
Minollo I.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.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.