W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2002

Re: minOccurs help?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 21 Jan 2002 11:50:15 +0000
Message-ID: <574277565.20020121115015@jenitennison.com>
To: "Neill Smith" <smith_neill@hotmail.com>
CC: xmlschema-dev@w3.org
Hi Neill,

> is minOccurs="0" the same as use="optional" ???
> I am confused between the 2?

use="optional" is used on an attribute reference or declaration to
state that a particular attribute is optional.

minOccurs="0" is used on a particle in a model group, and yes, it
means that the element (or model group - you can use minOccurs on
xs:sequence, xs:choice and so on) is optional.

> If so, does it mean that minOccurs="1" requires at least one entry?

Yes - the particle must occur a minimum of one time.

The reason you have minOccurs/maxOccurs on particles within a content
model is that, unlike attributes, you can have the same element
repeated any number of times in content. With attributes, the only
options are that it either has to be present (use="required") or that
it's optional (use="optional"). On the other hand, it's sometimes
useful to say that an element could occur between 5 and 100 times
(with minOccurs="5" and maxOccurs="100").

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 21 January 2002 06:50:16 GMT

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