Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-10-2009, 07:55 PM   PM User | #1
renting
New to the CF scene

 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
renting is an unknown quantity at this point
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.
renting is offline   Reply With Quote
Old 08-19-2009, 09:58 AM   PM User | #2
renting
New to the CF scene

 
Join Date: Aug 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
renting is an unknown quantity at this point
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>
renting is offline   Reply With Quote
Reply

Bookmarks

Tags
attribute, complextype, restriction

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:57 PM.


Advertisement
Log in to turn off these ads.