how to restrict the number of occurences

Hello all,
I have this code:

<xsd:complexType name="aliasEntryType">
<xsd:sequence>
<xsd:element name="alias" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="aliasEntryListType">
<xsd:sequence>
<xsd:element name="aliasEntryListElement" type="tns:aliasEntryType" minOccurs="0" nillable="true" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

and I have to modify it so that only one "alias" is accepted in "aliasEntryListElement" like this:

<aliasEntryListElement>
<alias>alias1</alias>
</aliasEntryListElement>
<aliasEntryListElement>
<alias>alias2</alias>
</aliasEntryListElement>

Could you please give me a hint?
Thanks in advance for all your help!

nadiamihu
[987 byte] By [nadiamihu] at [2007-11-20 11:55:04]
# 1 Re: how to restrict the number of occurences
The attributes minOccurs and maxOccurs let you limit the minimum and maximum times an element may appear, respectively.

<xsd:element name="myElement" minOccurs="1" maxOccurs="1" />
The above means <myElement> must appear, but only once. Note that this is also the default (so if you don't specify any minOccurs and maxOccurs attributes, they will both default to 1.)

"unbounded" can be used for maxOccurs to indicate that the element may appear an indefinite amount of times.

As for your problem, I think it'll be solved by removing the following attributes:
minOccurs="0" nillable="true" maxOccurs="unbounded"
Then it will default to requiring exactly one <alias> element.
andreasblixt at 2007-11-10 3:26:49 >