This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Attributes in Alphabetical Order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Attributes in Alphabetical Order" Watch "Attributes in Alphabetical Order" New topic
Author

Attributes in Alphabetical Order

John Lark
Ranch Hand

Joined: Feb 08, 2010
Posts: 72
Hey All,

I am storing xml in SQL Server, and then putting it into a document to send across the interweb. One thing I noticed upon recieving this XML document is that the attributes are in alphabetical order. For the most part I understand that this is irrelavent. I would like to know however what is causing this. Is it SQL or org.w3c.dom. I see a lot of people online pointing at org.w3c.dom, but was wondering if thats a standerd feature or if it means somthing was done incorrectly? does org.w3c.dom always alphabitise XML attributes? Is it possible SQL did it? I need to be able to explain why its happinig even if I dont need to change it so that it dosent happen.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

John Lark wrote:I need to be able to explain why its happinig.


No, you don't. The XML Recommendation (as it appears you already know) says the order of attributes is meaningless. Given that, there is no need to explain why any particular serializer outputs attributes in the order it outputs them. It suffices to say that they do what they do.

John Lark
Ranch Hand

Joined: Feb 08, 2010
Posts: 72
Thanks for the quick response, so then I can say confidently this is simply what the org.w3c.dom does?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

John Lark wrote:Thanks for the quick response, so then I can say confidently this is simply what the org.w3c.dom does?


Not really, no. Those classes store XML in a tree structure but as far as I know they don't serialize XML to a document. Look more closely at your code to see what's actually doing the serialization.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Attributes in Alphabetical Order
 
Similar Threads
Order of Attributes in a Node
Difference between Element and Node
how can i print an xml document through dom api
Xerces-2 Parsing to DOM and default attributes question
XML attributes serialization