Restricting a substitution group using <choice>

Yetanother issue raised by MSXML:

* Is it OK to restrict the members of a substitution group 
    by explicitly enumerating them in a <choice> group? 
* Does a substitution group include 2nd generation substitutions?

In the schema below, first I set up a couple of substitution groups 
- one is headed by an anyType element e4, and includes a string element e5,
an integer element e6 and a date element e7; 
- the other is headed by the integer element e6, and includes a
negativeInteger element e8 and a positiveInteger element e9.  

Then I define a complex type e4Container that merely contains an optional
e4.  

Then I define 2 complex types derived by restriction, 
in which I try to restrict the mebership of the e4 substitution group:

e6pContainer only allows e8 and e9
e4pContainer only allows e5, e7 and e8

MSXML says e6pContainer is OK, so it appears that second generation
substitutions are given the OK; 
but says e4pContainer has an "invalid particle derivation by restriction".  

This baffles me.  

Here's the schema:
========================

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://xmml.ned.dem.csiro.au/my"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:my="http://xmml.ned.dem.csiro.au/my" elementFormDefault="qualified"
attributeFormDefault="unqualified">
  <!-- -->
  <element name="e4" abstract="true"/>
  <element name="e5" type="string" substitutionGroup="my:e4"/>
  <element name="e6" type="integer" substitutionGroup="my:e4"/>
  <element name="e7" type="date" substitutionGroup="my:e4"/>
  <element name="e8" type="negativeInteger" substitutionGroup="my:e6"/>
  <element name="e9" type="positiveInteger" substitutionGroup="my:e6"/>
  <!-- -->
  <complexType name="e4Container" abstract="true">
    <sequence>
      <element ref="my:e4" minOccurs="0"/>
    </sequence>
  </complexType>
  <complexType name="e6pContainer">
    <complexContent>
      <restriction base="my:e4Container">
        <sequence>
          <choice minOccurs="0">
            <element ref="my:e8"/>
            <element ref="my:e9"/>
          </choice>
        </sequence>
      </restriction>
    </complexContent>
  </complexType>
  <element name="e6pC" type="my:e6pContainer"/>
  <complexType name="e4pContainer">
    <complexContent>
      <restriction base="my:e4Container">
        <sequence>
          <choice minOccurs="0">
            <element ref="my:e5"/>
            <element ref="my:e7"/>
            <element ref="my:e8"/>
          </choice>
        </sequence>
      </restriction>
    </complexContent>
  </complexType>  
  <element name="e4pC" type="my:e4pContainer"/><!--    -->
  <!-- -->
</schema>
_____
Simon.Cox@csiro.au  CSIRO Exploration & Mining
26 Dick Perry Avenue, Kensington WA 6151
PO Box 1130, Bentley WA 6102  AUSTRALIA
T: +61 (8) 6436 8639  F: +61 (8) 6436 8555  C: +61 (4) 0330 2672
http://www.csiro.au/page.asp?type=resume&id=CoxSimon

Received on Tuesday, 12 March 2002 03:30:59 UTC