W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

RE: is the best/only way to restrict the values of an attribute

From: Dare Obasanjo <dareo@microsoft.com>
Date: Mon, 15 Apr 2002 01:11:07 -0700
Message-ID: <8BD7226E07DDFF49AF5EF4030ACE0B7E05C69980@red-msg-06.redmond.corp.microsoft.com>
To: "Randy Eastwood" <sunmesa@cox.net>, "W3C XSchema List" <xmlschema-dev@w3.org>
I'm not sure if this is that much better, it does save a line or two. 


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="TEIMSettings">
 <xs:complexType>
  <xs:sequence>
    <xs:element name="LACAllowTIRUpload" type="allowAttribute"/>
    <xs:element name="LACAllowTIRDelete" type="allowAttribute"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

 <xs:complexType name="allowAttribute" >
  <xs:attribute name="allow" use="required"> 
   <xs:simpleType>
    <xs:restriction base="xs:string">
     <xs:enumeration value="YES"/>
     <xs:enumeration value="NO"/>
    </xs:restriction>
   </xs:simpleType>
  </xs:attribute>
 </xs:complexType>

</xs:schema>

Actually I'm wrong. Although it has fewer constructs it is longer. Go
figure. 

-- 
PITHY WORDS OF WISDOM 
Computers are not intelligent. They only think they are.
 
This posting is provided "AS IS" with no warranties, and confers no
rights. 
You assume all risk for your use. (c) 2002 Microsoft Corporation. All
rights reserved.



> -----Original Message-----
> From: Randy Eastwood [mailto:sunmesa@cox.net] 
> Sent: Monday, April 15, 2002 1:03 AM
> To: W3C XSchema List
> Subject: is the best/only way to restrict the values of an attribute
> 
> 
> 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.
> 
> Am I taking a bad approach here? It seems I have one layer to 
> many. How/Can I reduce?
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="TEIMSettings">
>  <xs:complexType>
>   <xs:sequence>
>     <xs:element name="LACAllowTIRUpload" type="allowAttribute"/>
>     <xs:element name="LACAllowTIRDelete" type="allowAttribute"/>
>   </xs:sequence>
>  </xs:complexType>
> </xs:element>
> 
> <xs:complexType name="allowAttribute" >
>  <xs:attribute name="allow" type="allowValues" 
> use="required"/> </xs:complexType>
> 
> <xs:simpleType name="allowValues">
>  <xs:restriction base="xs:string">
>   <xs:enumeration value="YES"/>
>   <xs:enumeration value="NO"/>
>  </xs:restriction>
> </xs:simpleType>
> 
> </xs:schema>
> 
> 
> 
> 
Received on Monday, 15 April 2002 04:11:18 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT