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

Re: XML Schema: element ordering

From: Robin LaFontaine <robin@monsell.co.uk>
Date: Wed, 12 Jul 2000 18:15:33 +0100
Message-Id: <v04210125b592566f946d@[158.152.20.130]>
To: ht@cogsci.ed.ac.uk (Henry S. Thompson)
Cc: xmlschema-dev@w3.org
Henry,

Thanks for your prompt reply to this query (you must spend a lot of 
your time answering these queries, and people like me appreciate that 
- thanks!).

The ordering seems to be more a property of the data than the 
application. XML Schema does have the concept of keys as part of the 
data integrity, and typically if an item has a key it can appear in 
any order. But I do see why you did not go down this route!

Perhaps I can be more specific and say that I am writing an 
application to determine whether two XML schemas are the same (or to 
indicate where they differ). So, it is important to know which 
elements can appear in a different order but make no difference to 
the schema definition.

This is what I 'guessed', but perhaps you can tell me if I am wrong 
(in this I have expanded all the entities and I am working with the 
DTD at this point):

These elements are not-ordered:
<!ELEMENT all
  ((annotation)?,
   (element | group | choice | sequence | any)*)>

<!ELEMENT attributeGroup
  ((annotation)?,
   (attribute | attributeGroup)*,
   (anyAttribute)?)>

<!ELEMENT choice
  ((annotation)?,
   (element | group | choice | sequence | any)*)>

<!ELEMENT element
  ((annotation)?,
   (complexType | simpleType)?,
   (unique | key | keyref)*)>

<!ELEMENT schema
  ((include | import | annotation)*,
   (simpleType | complexType | element | attribute | attributeGroup | 
group | notation),
   (annotation | simpleType | complexType | element | attribute | 
attributeGroup | group | notation)*)>

<!ELEMENT simpleType
  ((annotation)?,
   ( (minInclusive | minExclusive) |
    (maxInclusive | maxExclusive) | precision | scale | pattern | 
enumeration | length | maxLength | minLength | encoding | period | 
duration)*)>

<!ELEMENT unique
  ((annotation)?, selector,
   (field)+)>


These elements are ordered:

<!ELEMENT annotation
  (appinfo | documentation)*>

<!ELEMENT key
  ((annotation)?, selector,
   (field)+)>

<!ELEMENT keyref
  ((annotation)?, selector,
   (field)+)>

<!ELEMENT sequence
  ((annotation)?,
   (element | group | choice | sequence | any)*)>


These elements are a mixture:

<!ELEMENT complexType
  ((annotation)?,
   ( (  (minInclusive | minExclusive) |
     (maxInclusive | maxExclusive) | precision | scale | pattern | 
enumeration | length | maxLength | minLength | encoding | period | 
duration)* |
    (  (element | all | choice | sequence | group | any)*,
     (attribute | attributeGroup)*,
     (anyAttribute)?)))>

The first repeating CP is unordered, the second ordered and the third 
unordered.

Are my guesses correct?

Kind regards,
Robin

At 4:43 pm +0100 12/7/00, Henry S. Thompson wrote:
>Robin LaFontaine <robin@monsell.co.uk> writes:
>
> > There is a basic requirement for most data structures to distinguish
> > between a 'list', which is ordered, and a 'set' which is not.
> >
> >
> > I cannot see how, in XML Schema, to make this distinction.
> >
> > For example:
> >
> >     <element name="CoordGeom">
> >             <complexType>
> >               <choice minOccurs="0" maxOccurs="unbounded">
> >                   <element ref="Line"/>
> >                   <element ref="Curve"/>
> >                   <element ref="Spiral"/>
> >               </choice>
> >             </complexType>
> >     </element>
> >
> > How can I indicate if the sequence of element instances within the
> > choice is significant ('list') or not ('set')?
> >
> >
> > I have not been able to determine the answer to this question from
> > reading the spec, except that by omission I think the answer is 'you
> > cannot do this in XML Schema'!
>
>You cannot _say_ this in XML Schema.  You can do it just fine, but
>it's down to applications to know when order is significant in ordered
>elements and when it isn't.
>
>One way to think about this is: On the simple type side, we define
>both type-specific lexical and value spaces.  On the complex type
>side, we define type-specific lexical spaces, but only a generic value
>space, based on the XML Infoset model.  The children of element
>information items are ordered in that model:  whether that order has
>application significance or not is not expressable at the infoset
>level.
>
>Given the difficulties of specifying a universal application data
>model for complex types, the WG decided not to step even a little bit
>down on to the slippery slope that allowing people to say 'list, set,
>bag, poset, ...' would represent.
>
>ht
>--
>  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
>          W3C Fellow 1999--2001, part-time member of W3C Team
>     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
>	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
>		     URL: http://www.ltg.ed.ac.uk/~ht/

-- -----------------------------------------------------------------
Robin La Fontaine, Monsell EDM Ltd
(R&D Project Management, Engineering Data Exchange using XML, EDIF)
Tel: +44 1684 592 144 Fax: +44 1684 594 504 or +44 870 054 2811
Email: robin@monsell.co.uk       http://www.monsell.co.uk
Received on Wednesday, 12 July 2000 13:14:15 GMT

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