Re: Pls do the need full

Hi Ibrahim,

> I'm new to XML schema development so my question might be really
> very simple. I want to know how to find out an element is mandatory
> or optional from xml schema.

Whether or not an element is mandatory or optional within a particular
other element depends on the *content model* of that other element.
You'll see things like:

  <xs:sequence>
    <xs:element name="E1" />
    <xs:element ref="E2" minOccurs="0" />
    <xs:element name="E3" minOccurs="3" maxOccurs="unbounded" />
  </xs:sequence>

within a schema.

Whether a particular element is mandatory or optional depends on
whether it has a minOccurs attribute and what the value of that
minOccurs attribute is. The minOccurs attribute specifies the minimum
number of times that the element must occur. If it's one or more then
the element must occur. If it's zero, then the element is optional. If
the minOccurs attribute is missing, it's the same as specifying it
with the value 1.

So in the model group above, element E1 is mandatory (minOccurs is
missing, so it defaults to 1), element E2 is optional (minOccurs is 0)
and element E3 is mandatory (in fact must occur at least three times).

The maxOccurs attribute similarly indicates the maximum number of
times the element can occur, defaults to 1 if it's missing, and can
take the value 'unbounded' to mean "there's no maximum".

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 19 April 2002 05:04:04 UTC