Java Reference
In-Depth Information
<xs:element name="recipe">
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
<xs:element ref="ingredients"/>
<xs:element ref="instructions"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Thisdeclarationstatesthat
recipe
isacomplextype(viathe
complexType
ele-
ment) consisting of a sequence (via the
sequence
element) of one
title
element
followedbyone
ingredients
elementfollowedbyone
instructions
element.
Each of these elements is declared by a different
element
that is referred to by its
element
's
ref
attribute.
The next complex type to declare is
ingredients
. The following example
provides its declaration:
<xs:element name="ingredients">
<xs:complexType>
<xs:sequence>
<xs:element
ref="ingredient"
maxOc-
curs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
This declaration states that
ingredients
is a complex type consisting of a se-
quenceofoneormore
ingredient
elements.The“ormore”isspecifiedbyincluding
element
's
maxOccurs
attribute and setting this attribute's value to
unbounded
.
Note
The
maxOccurs
attribute identifies the maximum number of times that an
elementcanoccur.Asimilar
minOccurs
attributeidentifiestheminimumnumberof
timesthatanelementcanoccur.Eachattributecanbeassigned0orapositiveinteger.
Furthermore,youcanspecify
unbounded
for
maxOccurs
,whichmeansthatthere
isnoupperlimitonoccurrencesoftheelement.Eachattributedefaultstoavalueof1,
whichmeansthatanelementcanappearonlyonetimewhenneitherattributeispresent.