Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    setting attribute in complextype restriction

    I have the following code:

    Code:
    	<xs:complexType name="Frequency">
    		<xs:simpleContent>
    			<xs:extension base="xs:double">
    				<xs:attribute name="units" use="required">
    					<xs:simpleType>
    						<xs:restriction base="xs:string">
    							<xs:enumeration value="Hz"/>
    							<xs:enumeration value="KHz"/>
    							<xs:enumeration value="MHz"/>
    							<xs:enumeration value="GHz"/>
    						</xs:restriction>
    					</xs:simpleType>
    				</xs:attribute>
    			</xs:extension>
    		</xs:simpleContent>
    	</xs:complexType>
    Code:
    <xs:complexType name="ClockType">
    		<xs:simpleContent>
    			<xs:restriction base="Frequency">
    				<xs:enumeration value="160"/>
    				<xs:enumeration value="200"/>
    			</xs:restriction>
    		</xs:simpleContent>
    	</xs:complexType>
    My problem is, that for the life of me, I can't figure out how to set the units attribute when restricting Frequency in ClockType. What I want to do is have ClockType be either 160MHz or 200MHz.

    Does anyone have a clue how to do this?

    Thank you for any replies.

  • #2
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I got some help elsewhere and figured out a way to do this:

    Code:
      <xs:simpleType name="frequencyunit">
        <xs:restriction base="xs:string">
          <xs:enumeration value="Hz" />
          <xs:enumeration value="KHz" />
          <xs:enumeration value="MHz" />
          <xs:enumeration value="GHz" />
        </xs:restriction>
      </xs:simpleType>
      <xs:complexType name="Frequency">
        <xs:simpleContent>
          <xs:extension base="xs:double">
            <xs:attribute name="units" type="frequencyunit" use="required" />
          </xs:extension>
        </xs:simpleContent>
      </xs:complexType>
      <xs:complexType name="ClockType">
        <xs:simpleContent>
          <xs:restriction base="Frequency">
            <xs:enumeration value="160" />
            <xs:enumeration value="200" />
            <xs:attribute fixed="MHz" name="units" type="frequencyunit" use="required" />
          </xs:restriction>
        </xs:simpleContent>
      </xs:complexType>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •