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:complexType>
		<xs:sequence>
			<xs:element ref="Grade" minOccurs="0" />
		</xs:sequence>
	</xs:complexType>
</xs:element>
<xs:element name="Grade">
	<xs:complexType mixed="true">
		<xs:simpleContent>
			<xs:extension base="GradeType">
				<xs:attribute name="_Code"
type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
</xs:element>
<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:restriction>
</xs:simpleType>

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

Thanks,
Adam


Regards,
Adam

Adam Fortuno
Business Process Architect
Metavante Lending Solutions
http://www.ghrsystems.com
AIM:    fortunoar
Received on Wednesday, 20 December 2006 20:41:46 GMT

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