W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2001

Extension of Enumerations

From: Michael Zoratti <m.zoratti@nortelnetworks.com>
Date: Tue, 5 Jun 2001 14:10:44 -0500
Message-ID: <CEDFCAE711ADD4118B030008C7E674A41CA593@nbrwd469.ca.nortel.com>
To: "'www-xml-schema-comments@w3.org'" <www-xml-schema-comments@w3.org>


  I have posted in the past, a workaround (using substitution groups) that
a possible solution to the problem of extensions of Enumerations.


Note: Extensions of Enumeration is currently not supported in the
current definition in XML Schema Language.

Below I have provided another possibility which is a much more cleaner and
more strongly typed solution.  I would like any feedback specifically
this proposed solution violates the XML Schema Language definition.

	First you wrap your standard Enumeration declaration in a Complex

	1)    <complexType name="OrderState">
				<element name="Value"
type="en:OrderStateEnum" nullable="true"/>

	        Note: OrderStateEnum is your standard simpleType

	Second if you want to add to this base set of enumerations you first
declare a complexType
	which extends from OrderState, the derivation is by Restriction.
Derivation by Restriction
	allows you to modify the parent complexType declarations, and in
affect change the type of the Value element.
	The Value element of this complexType will be of type
OrderStateEnumExtended. Therefore in
	XML instance documents you could either (using xsi:type) refer to
OrderState, or OrderStateExtended and the
	sets of enumerations will be different. The structure and the
element names ;however, would be

	2)  <complexType name="OrderStateExtended">
			<restriction base="en:OrderState">
				     <element name="Value"

This solution validates using XMl Spy and so do the XML instance documents,
although I think this
may be invalid in regards to the definition in the XML Spec. In the spec it
says you may 
declare a type in the restricted complexType however is states 
"specifying a type where none was previously given" (Section 4.4).

below are the examples.

I appreciate your comments

Mike Zoratti
Software Architect
Nortel Networks

	 <<Enumerations.xsd>>  <<EnumerationExtended.xml>>  

Received on Tuesday, 5 June 2001 18:16:37 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:49:56 UTC