W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > October to December 1999

Re: Question on "minOccurs" within element declarations

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 21 Dec 1999 12:07:48 +0000
To: www-xml-schema-comments@w3.org
Message-ID: <f5b4sdcqyy3.fsf@cogsci.ed.ac.uk>
[retransmission to the lists for the record]

Jamieson Christian wrote:

> In section 3.4.9, dealing with <element> declarations, the minOccurs
> attribute for an <element> can only be "1" or (presumably) not be present at
> all to indicate no minimum occurrence restriction.  (The examples indicate
> that minOccurs can be explicitly included with a "0" value, although the
> formal grammar does not indicate this.)  But why must the attribute value
> stop at "1"?  Certain applications may call for some minimum number of
> occurrences greater than 1.  Consider XML data that tracks bus routes by
> bus, arranged as follows.  (Details for each stop location may be stored
> separately, e.g. in top-level <site> elements.)

> <bus id="METSOU-037" name="Metro South">
>         <location arrive="09:36" depart="09:38" site="5TH-026" />
>         <location arrive="09:42" depart="09:44" site="MAIN-019" />
>         <!-- Additional location codes -->
> </bus>

> In order for a bus to have a route, it must go between at least TWO
> locations, so at least two <location> elements need to be included.  The XML
> Schema should be able to enforce this.  An example (abbreviated) schema
> would be:

> <archetype name="bus">
>         <element name="location" minOccurs="2">
>                 <!-- Embedded archetype for element "location" -->
>         </element>
> </archetype>

> Simon, is this similar to what you were referring to you in your P.S.?
> (Ref. message ID
> 3D808EC801AED111B0100008C75D5DDCF0BB55@roc05bxgeisge.is.ge.com, November 23,
> 1999.)

> Best regards,
> Jamieson Christian
> TRW Systems & Information Technology Group
> mailto:Jamieson.Christian@trw.com

> NOTE: The opinions expressed herein are solely those of the author and do
> not necessarily reflect the views or opinions of TRW.

The element syntax summary has misled you -- the Schema for Schemas

  <attrGroup name='occurs'>
    <attribute name='minOccurs' type='non-negative-integer' default='1'/>
    <attribute name='maxOccurs' type='string'/> <!-- allows '*', so integer
                                                       won't do -->

So any value from 0 upwards is OK for minOccurs, and from minOccurs on 
up for maxOccurs.

We're looking at better ways of summarising the concrete syntax in the 

  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
     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 Tuesday, 21 December 1999 07:07:53 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:49:51 UTC