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

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 UTC