Is there a way I can ensure that only
one of these values can be entered
inside the element?
是的,含有XML Evidation 。 这里的一个例子是货币:
<xsd:simpleType name = "iso3currency">
<xsd:restriction base = "xsd:string">
<xsd:enumeration value = "AUD"/><!-- Australian Dollar -->
<xsd:enumeration value = "BRL"/><!-- Brazilian Real -->
<xsd:enumeration value = "CAD"/><!-- Canadian Dollar -->
<xsd:enumeration value = "CNY"/><!-- Chinese Yen -->
<xsd:enumeration value = "EUR"/><!-- Euro -->
<xsd:enumeration value = "GBP"/><!-- British Pound -->
<xsd:enumeration value = "INR"/><!-- Indian Rupee -->
<xsd:enumeration value = "JPY"/><!-- Japanese Yen -->
<xsd:enumeration value = "RUR"/><!-- Russian Rouble -->
<xsd:enumeration value = "USD"/><!-- US Dollar -->
<xsd:length value = "3"/>
</xsd:restriction>
这把该要素的价值限制在列出的计算值之一和3年的长度。
为此,您必须通过validator。 这方面的一个例子。 该网络在此:
HOW TO: Validate XML Fragments Against an XML Schema in Visual C#.NET
http://support.microsoft.com/kb/318504