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

Boris Kolpackov boris at codesynthesis.com
Fri Sep 13 06:39:35 EDT 2013


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