- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Tue, 12 Mar 2002 11:28:37 +0000
- To: Simon.Cox@csiro.au
- CC: xmlschema-dev@w3.org, dareo@microsoft.com
Hi Simon, > * Is it OK to restrict the members of a substitution group > by explicitly enumerating them in a <choice> group? Yes. > * Does a substitution group include 2nd generation substitutions? Yes. > 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". The problem is to do with the ordering of the elements in the choice that you're using. This is an area where XML Schema is underdefined; MSXML has chosen one way of doing it... Normally when you restrict a choice with another choice, the particles within the two choices have to be in the same order as each other. So if you have: <choice> <element ref="e1" /> <element ref="e2" /> <element ref="e3" /> </choice> then the following restriction is OK: <choice> <element ref="e1" /> <element ref="e3" /> </choice> but the following restriction is not OK because there's not an order-preserving map between the particles in the base type and those in the restricted type: <choice> <element ref="e3" /> <element ref="e1" /> </choice> The XML Schema Rec states that you can replace the head of a substitution group with a choice that contains one particle per member of the substitution group. Starting from: <sequence> <element ref="my:e4" minOccurs="0"/> </sequence> It appears that MSXML substitutes the elements in order - first the head of the substitution group, then the members of the substitution group in the order in which they are declared. So you get: <sequence> <choice minOccurs="0"> <element ref="my:e4" /> <element ref="my:e5" /> <element ref="my:e6" /> <element ref="my:e7" /> </choice> </sequence> and then: <sequence> <choice minOccurs="0"> <element ref="my:e4" /> <element ref="my:e5" /> <choice> <element ref="my:e6" /> <element ref="my:e8" /> <element ref="my:e9" /> </choice> <element ref="my:e7" /> </choice> </sequence> The second choice is "pointless", so it gets removed, to give you: <sequence> <choice minOccurs="0"> <element ref="my:e4" /> <element ref="my:e5" /> <element ref="my:e6" /> <element ref="my:e8" /> <element ref="my:e9" /> <element ref="my:e7" /> </choice> </sequence> Note the ordering of the elements in the choice group, in particular that the reference to e8 comes before the reference to e7. In your restriction for the e4pContainer, you had: <sequence> <choice minOccurs="0"> <element ref="my:e5"/> <element ref="my:e7"/> <element ref="my:e8"/> </choice> </sequence> With e8 *after* e7. If you swap them around: <sequence> <choice minOccurs="0"> <element ref="my:e5"/> <element ref="my:e8"/> <element ref="my:e7"/> </choice> </sequence> Then MSXML validates without complaining. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Tuesday, 12 March 2002 06:28:38 UTC