how do i make sure an element only takes on a certain set of values
Hi:
another question, :$ how do i make sure an element only takes on a certain set of values ? what i mean is the following,
suppose i have an element called <type>, now <type> can only takes on event, classifed and QandA
<type>event</type>
<type>classifed</type>
<type>QandA</type>
now, how would I be able to specify that in the schema?
<xs:element name="phone">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[event][classifed][QandA]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
[/code]
is the above correct? pleaset let me know..
many thanks
[774 byte] By [
doglin] at [2007-11-19 14:02:46]

# 1 Re: how do i make sure an element only takes on a certain set of values
In your case the <xsd:enumaration> is more than enough
and probably the best solution:
<xs:element name="phone">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="event"/>
<xs:enumeration value="classifed"/>
<xs:enumeration value="QNA"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Hi:
another question, :$ how do i make sure an element only takes on a certain set of values ? what i mean is the following,
suppose i have an element called <type>, now <type> can only takes on event, classifed and QandA
<type>event</type>
<type>classifed</type>
<type>QandA</type>
now, how would I be able to specify that in the schema?
<xs:element name="phone">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[event][classifed][QandA]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
[/code]
is the above correct? pleaset let me know..
many thanks