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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Thursday, 17 July 2003 06:33:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:39 GMT