In addition to order indicators, occurrence indicators can be specified. Occurrence indicators specify how often an element can occur within an element. The default value for an occurrence indicator is 1. The two types of occurrence indicators are maxOccurs and minOccurs. The following table describes both. |
Indicator |
Description |
Example |
|
Specifies the maximum number of times an element can occur |
<xs:element name="mail">
<xs:complexType>
<xs:sequence>
<xs:element
name="from"
type="xs:string"/>
<xs:element name="to"
type="xs:string"
maxOccurs="10"/>
</xs:sequence>
</xs:complexType>
</xs:element>
The to element can occur a maximum of ten times and a minimum of one time within the mail element.
|
|
Specifies the minimum number of times an element can occur |
<xs:element
name="EmpDetails">
<xs:complexType>
<xs:sequence>
<xs:element name="EmpName" type="xs:string"/>
<xs:element name="projects" type="xs:string"
minOccurs="2" maxOccurs="5" />
</xs:sequence>
</xs:complexType>
</xs:element>
The projects element can occur a minimum of two times and a maximum of five times within the EmpDetails element.
|
Note that order and occurrence indicators are specified only for complex type elements.
|