Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: noah_mendelsohn@--.---.---
To: "Fortuno, Adam" <Adam_Fortuno@----------.--->
Date: 12/19/2006 5:10:00 AM
I think you want something closer to:

                  <xs:simpleType name="CodeType">
                                 <xs:restriction base="xs:token">
                                                 <xs:enumeration 
value="ABC" />
                                                 <xs:enumeration 
value="123" />
                                                 <xs:enumeration 
value="DEF" />
                                 </xs:restriction>
                  </xs:simpleType>

                 <xs:complexType name="FooType>
                <xs:simpleContent>
                      <xs:extension base="CodeType">
                                  <xs:attribute name="_Code" 
type="xs:string"/>
                      </xs:extension>
                <xs:simpleContent>
                 </xs:complexType>


                 <xs:element name="Foo" type="FooType"/>


Explanation:

Simple types define string-like content.  In this case, you are defining a 
new one for the CodeType that will be used to constrain the string-like 
content of the element character children.  The type of the element itself 
is complex, because it has attributes too.  We're defining FooType for 
that.  It states that it has simple (I.e. string-like) content, but is 
extended to allow an attribute.  The attribute _Code is of type xs:string.

I haven't run this through a validator, but I think it's either right or a 
few typos away.  Obviously, you could flip this around to have codes in 
the attribute and string in the element by doing:

                  <xs:simpleType name="CodeType">
                                 <xs:restriction base="xs:token">
                                                 <xs:enumeration 
value="ABC" />
                                                 <xs:enumeration 
value="123" />
                                                 <xs:enumeration 
value="DEF" />
                                 </xs:restriction>
                  </xs:simpleType>

                 <xs:complexType name="FooType>
                <xs:simpleContent>
                      <xs:extension base="xs:string">
                                  <xs:attribute name="_Code" 
type="CodeType"/>
                      </xs:extension>
                <xs:simpleContent>
                 </xs:complexType>


                 <xs:element name="Foo" type="FooType"/>


Good luck!

Noah

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------





From Adam_Fortuno@e... Wed Dec 20 20:41:46 2006
Received: from maggie.w3.org ([193.51.208.68])
	by frink.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent