Using substitution groups as meta-types

(In case the alignment of the xml in this message arrives and is difficult
to read, I've attached a Word document with the same question. The Word doc
also contains XML Spy diagrams.)

  <<Substitution group in metaclass.doc>> 

If a substitution group is used to define a metaclass, can/should class and
instance be constrained by that definition?

Specifically, let's say I have an abstract type Phrase:

	<xs:complexType name="Phrase" abstract="true">
		<xs:sequence>
			<xs:element ref="Verb"/>
			<xs:element ref="Object"/>
		</xs:sequence>
	</xs:complexType>

with the intent that the elements "Verb" and "Object" are the abstract heads
of substitution groups:

	<xs:element name="Verb" type="Verb" abstract="true"/>
	<xs:element name="Object" type="Noun" abstract="true"/>

with parallel supporting complexTypes:

	<xs:complexType name="Verb" abstract="true"/>
	<xs:complexType name="Object" abstract="true"/>

(that is, every Verb element is something that has the type Verb, likewise
with every Object).

Now, I would like to define, within the schema, a specific phrase, based on
the complexType "Phrase", with a specific Verb substituting for the abstract
Verb and a specific Object substituting for the abstract Object:

	<xs:element name="ProcessPurchaseOrder" >
		<xs:complexType>
			<xs:complexContent>
				<xs:restriction base="Phrase">
					<xs:sequence>
						<xs:element name="Process"
type="Process"/>
						<xs:element
name="PurchaseOrder" type="PurchaseOrder"/>
					</xs:sequence>
				</xs:restriction>
			</xs:complexContent>
		</xs:complexType>
	</xs:element>

Note the restriction on base type "Phrase" and the replacement of the
abstract head element Verb and Object with Process and PurchaseOrder,
respectively.

The complexType Process is an extension of the type Verb and complexType
PurchaseOrder is an extension of the type Object:

	<xs:complexType name="Process">
		<xs:complexContent>
			<xs:extension base="Verb">
		...
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<xs:complexType name="PurchaseOrder">
		<xs:complexContent>
			<xs:extension base="Object">
		...
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	
Finally, the elements Process and PurchaseOrder are defined in the
appropriate substitution groups:

	<xs:element name="Process" type="Process" substitutionGroup="Verb"/>
	<xs:element name="PurchaseOrder" type="PurchaseOrder"
substitutionGroup="Object"/>

I have tried this representation out, and it appears to be allowed by XSV,
Xerces, and XML Spy. However, when I include a Verb or Object that is not in
the appropriate respective substitution group, none of the validators
reports an error.

My questions are:

1.	should schema validators reject any "Phrase" specialization that
contains a Verb child or Object child that is not a member of its respective
substitution group?
2.	should schema validators reject an instance document containing a
specific phrase element that names a  Verb child or Object child that is not
a member of its respective substitution group?
3.	By using these constructs "at the metalevel", am I using the
substitution group mechanism in a way that is not intended to be used?



----------------------------------------------------------------------------
----
 
Mark Feblowitz                                   [t] 617.715.7231
Frictionless Commerce Incorporated     [f] 617.495.0188 
XML Architect                                     [e]
mfeblowitz@frictionless.com
400 Technology Square, 9th Floor 
Cambridge, MA 02139 
www.frictionless.com  
 

Received on Wednesday, 7 November 2001 11:32:32 UTC