RE: Questions Regarding Complex Type Restrictions

Hi again Robert,

It looks like you are trying to restrict and extend (by adding
attributes) at the same time.  You have to do it in two steps, so it
would look something like:

<simpleType name="restrictedFloat">
		<xs:restriction base="xs:float">
			<xs:minInclusive value="36.0"/>
			<xs:maxInclusive value="100.0"/>
		</xs:restriction>
</simpleType>

<xs:element name="height">
	<xs:complexType>
        <xs:simpleContent>
         <xs:extension base="restrictedFloat">
		<xs:attribute name="units" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:token">
					<xs:enumeration value="in"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="display1" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:token">
					<xs:enumeration value="ft"/>
					<xs:enumeration value=""/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="display2" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:token">
					<xs:enumeration value="in"/>
					<xs:enumeration value="cm"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
         </xs:extension>
        </xs:simpleContent>
	</xs:complexType>
</xs:element>

Hope that helps!

Priscilla
-----------------------------------------------------
Priscilla Walmsley             priscilla@walmsley.com
Author, Definitive XML Schema     (Prentice Hall PTR)
----------------------------------------------------- 

-----------------------------------------------------
Priscilla Walmsley             priscilla@walmsley.com
Author, Definitive XML Schema     (Prentice Hall PTR)
----------------------------------------------------- 

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Robert McCarthy
> Sent: Wednesday, May 22, 2002 10:30 AM
> To: xmlschema-dev@w3c.org
> Subject: Questions Regarding Complex Type Restrictions
> 
> 
> Is the following syntax valid?  Is there a better way to 
> specify this block
> of statements?  Perhaps some explanation will help.  I have 
> an element named
> "height" that will be entered on a user interface in any one of the
> following formats: feet and inches, just inches, or just 
> centimeters.  The
> business logic will always convert these values to inches 
> before saving them
> in an XML file, and the value of inches must be between 36.0 
> and 100.0,
> inclusive.  I have three attributes: (1) "units" which will always be
> "inches", (2) "display1" will either contain "ft" or nothing, and (3)
> "display2" will either contain "in" or "cm".  "display1" and 
> "display2" are
> used to indicate how to convert and display "height" to the 
> proper format
> and value when displaying it on the user interface.
> 
> Thanks!
> 
> - Robert
> 
> <xs:element name="height">
> 	<xs:complexType>
> 		<xs:restriction base="xs:float">
> 			<xs:minInclusive value="36.0"/>
> 			<xs:maxInclusive value="100.0"/>
> 		</xs:restriction>
> 		<xs:attribute name="units" use="required">
> 			<xs:simpleType>
> 				<xs:restriction base="xs:token">
> 					<xs:enumeration value="in"/>
> 				</xs:restriction>
> 			</xs:simpleType>
> 		</xs:attribute>
> 		<xs:attribute name="display1" use="required">
> 			<xs:simpleType>
> 				<xs:restriction base="xs:token">
> 					<xs:enumeration value="ft"/>
> 					<xs:enumeration value=""/>
> 				</xs:restriction>
> 			</xs:simpleType>
> 		</xs:attribute>
> 		<xs:attribute name="display2" use="required">
> 			<xs:simpleType>
> 				<xs:restriction base="xs:token">
> 					<xs:enumeration value="in"/>
> 					<xs:enumeration value="cm"/>
> 				</xs:restriction>
> 			</xs:simpleType>
> 		</xs:attribute>
> 	</xs:complexType>
> </xs:element>
> 
> 
> 
> 

Received on Friday, 24 May 2002 08:32:52 UTC