Re: XML Schema: element ordering

Robin LaFontaine <robin@monsell.co.uk> writes:

> 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!).

You're welcome.

> 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.

Maybe that's true for data from databases, but it certainly is _not_
true for data from documents -- consider the keys on the chapters of a 
book!

> 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.

Interesting -- at some point I'll release the canonicalisation tool I
use for comparing schemas.

> 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)*>

I'd say not, actually

> <!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?

I've noted one disagreement above.

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/

Received on Thursday, 13 July 2000 04:59:07 UTC