- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Mon, 15 Apr 2002 09:49:12 +0100
- To: "Randy Eastwood" <sunmesa@cox.net>
- CC: "W3C XSchema List" <xmlschema-dev@w3.org>
Hi Randy, > Can someone tell me if this is the best/only way to restrict the > values of an attribute? I only have one attribute named "allow" and > I want it to be either YES or NO. As well as nesting the simple type of the attribute, as Dare showed you, the other change you could make would be to restrict from xs:token instead of xs:string: <xs:simpleType name="allowValues"> <xs:restriction base="xs:token"> <xs:enumeration value="YES"/> <xs:enumeration value="NO"/> </xs:restriction> </xs:simpleType> The only difference between the two is how whitespace is treated. When you restrict from xs:string, the value of the attribute has to literally be the enumerated value that you specify, so for example: <LACAllowTIRUpload allow="YES" /> would be valid but: <LACAllowTIRUpload allow=" YES " /> would be invalid. If you restrict from xs:token, then both are valid. The reason I suggest this is because other XML Schema simple types treat whitespace like xs:token rather than xs:string. For example: <date xsi:type="xs:date"> 2002-04-15 </date> is valid because the whitespace is stripped during validation. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Monday, 15 April 2002 05:10:05 UTC