[xsd-users] Can I influence the order of attribute serialization?

Chris Delnooz Chris.Delnooz at hydrix.com
Sun Sep 15 17:32:33 EDT 2013


Hi Boris,

Thanks, that explains what I see happening.  I wanted it in a specific order to avoid discussion later on ;) But I'll manage with the way it works now. No worries.

Thanks!
Chris

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Friday, 13 September 2013 8:40 PM
To: Chris Delnooz
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Can I influence the order of attribute serialization?

Hi Chris,

Chris Delnooz <Chris.Delnooz at hydrix.com> writes:

> However, if I look at the serialized code, it doesn't respect the 
> order in which the attributes were specified:

XSD (i.e., the generated code) actually serializes them in the order specified in the schema. This is Xerces-C++ behvaior. Generally, in XML, the order of attributes is not significant and is not preserved.
Xerces-C++, for example, stores them in a map (keyed to the attribute
name; for easier lookup) and when it comes time to serialize, it simply writes them in that order, which is why you end up with an alphabetically sorted list.

Do you need them in a specific order for aesthetic purposes or for some other reason (e.g., a non-conforming XML parser on the other end)?

Boris



More information about the xsd-users mailing list