W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2006

RE: Element Takes Enumerated List but has Attribute that Takes a String

From: Fortuno, Adam <Adam_Fortuno@ghrsystems.com>
Date: Wed, 20 Dec 2006 15:41:29 -0500
Message-ID: <CED447ECB4C001419947EBF4776E503282F164@ghrintallmsg2.CORPORATE.GHRSYS.AD>
To: <xmlschema-dev@w3.org>

Michael, Marie, and Noah,

Thank you! I really-really appreciate your assistance.

I was actually able to figure this out last Friday. The solution I ended
up using is at the bottom of this note. None the less, I tried your
suggestions yesterday.

Mike> <xs:element name="Foo">
Mike> 	<xs:complexType>
Mike>        <xs:simpleContent>
Mike> 	 	<xs:restriction base="xs:token">
Mike> 			<xs:enumeration value="Opt1" />
Mike> 			<xs:enumeration value="Opt2" />
Mike> 			<xs:enumeration value="Opt3" />
Mike> 	     	</xs:restriction> 			 
Mike>        </xs:simpleContent>
Mike>        <xs:attribute name="_Code" type="xs:string"/>
Mike> 	</xs:complexType>
Mike> </xs:element>

Mike, This didn't work when I tried it. In XML Spy, I'd get errors
reading, "Element <xs:attribute> is not allowed at this location under
element <xs:complexType>. Reason: No more elements expected." I had
tried this before with (if I remember right) the same result.

Marie, I think I see where you were going with this. I think you and I
were thinking on the same lines.

Noah, I had to fix some little things (add double quote, etc.), but your
suggestion was right on the money. I appreciate the explenation as well.

All, below is the markup I actually used. 

<!-- Markup Actually Used -->
<xs:element name="MainNode">
			<xs:element ref="Grade" minOccurs="0" />
<xs:element name="Grade">
	<xs:complexType mixed="true">
			<xs:extension base="GradeType">
				<xs:attribute name="_Code"
<xs:simpleType name="GradeType">
	<xs:restriction base="xs:token">
		<xs:enumeration value="Excellent"/>
		<xs:enumeration value="Acceptable"/>
		<xs:enumeration value="Poor"/>
		<xs:enumeration value="Failure"/>

<xs:element name="Foo">
	 <xs:restriction base="xs:token">
		<xs:enumeration value="ABC" />
		<xs:enumeration value="123" />
		<xs:enumeration value="DEF" />
       <xs:attribute name="_Code" type="xs:string"/>



Adam Fortuno
Business Process Architect
Metavante Lending Solutions
AIM:    fortunoar
Received on Wednesday, 20 December 2006 20:41:46 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:38 UTC