schema, specifying alternatives

S

shaun roe

This is probably an easy question for someone, but not me:

In a W3C schema I should like to specify that an element can contain
EITHER multiple instances of one entity OR just one instance of another.

e.g. element <bed> will be allowed to have up to seven instances of
element <dwarf> OR one instance of element <snow_white>, but the
occurrence of both <snow_white> and even one <dwarf> in the same <bed>
is not allowed.

does it help/hinder if the character of the element is specified as an
attribute instead of the element name? e.g. <character type="dwarf">,
<character type="snow_white>
 
S

Steve Jorgensen

This is probably an easy question for someone, but not me:

In a W3C schema I should like to specify that an element can contain
EITHER multiple instances of one entity OR just one instance of another.

e.g. element <bed> will be allowed to have up to seven instances of
element <dwarf> OR one instance of element <snow_white>, but the
occurrence of both <snow_white> and even one <dwarf> in the same <bed>
is not allowed.

does it help/hinder if the character of the element is specified as an
attribute instead of the element name? e.g. <character type="dwarf">,
<character type="snow_white>

<xs:element name="bed">
<xs:complexType>
<xs:choice>
<xs:element ref="snow_white">
<xs:element ref="dwarf" maxOccurs="7">
</xs:choice>
</xs:complexType>
<xs:element>
 
S

Steve Jorgensen

<xs:element name="bed">
<xs:complexType>
<xs:choice>
<xs:element ref="snow_white">
<xs:element ref="dwarf" maxOccurs="7">
</xs:choice>
</xs:complexType>
<xs:element>

Oops - forgot to close all the tags...

<xs:element name="bed">
<xs:complexType>
<xs:choice>
<xs:element ref="snow_white"/>
<xs:element ref="dwarf" maxOccurs="7"/>
</xs:choice>
</xs:complexType>
</xs:element>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,092
Latest member
vinaykumarnevatia1

Latest Threads

Top