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>


Hello

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

http://lists.w3.org/Archives/Public/www-xml-schema-comments/2001AprJun/0022.
html

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
whether
this proposed solution violates the XML Schema Language definition.

	First you wrap your standard Enumeration declaration in a Complex
Type

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

	        Note: OrderStateEnum is your standard simpleType
enumeration.


	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
	same.

	2)  <complexType name="OrderStateExtended">
		<complexContent>
			<restriction base="en:OrderState">
				<sequence>
				     <element name="Value"
type="en:OrderStateEnumExtended"/>
				</sequence>
			</restriction>
		</complexContent>
	</complexType>

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>>  
<<Enumeration.xml>> 



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

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:12:50 GMT