W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2003

Re: order of attributes

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 17 Jul 2003 11:33:37 +0100
Message-ID: <171864667606.20030717113337@jenitennison.com>
To: COLLARD Jean-Francois <jean-francois.collard@swift.com>
CC: xmlschema-dev@w3.org

Hi Jean-Francois,

> Using a xml schema, how is it possible to impose the order of the
> attributes on a element in a xml instance? eg : on the element
> 'elem1' I want the attributes to appear in the order : first 'att1'
> then 'att2' and finally 'att3'.

The XML Rec says that the order in which attributes appear in a start
tag is insignificant. XML parsers are free to report the order of
attributes in any way that they like -- for example, they might report
them in alphabetical order if that makes the parser more efficient.

All the schema languages I know of, including XML Schema, work based
on the information that they can get from an XML parser. Since that
set of information doesn't include information about how the
attributes were originally ordered, no schema language gives you the
ability to check the order in which the attributes were specified.

So if this is really an important constraint in your documents, you
need to write a validator (in Perl or some other text-processing
language) that views the documents as streams of characters rather
than with the logical view that XML parsers provide. Most probably,
though, you should be using elements instead of attributes if the
order in which the information appears actually matters.



Jeni Tennison
Received on Thursday, 17 July 2003 06:33:42 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:02 UTC