- From: <Simon.Cox@csiro.au>
- Date: Fri, 15 Mar 2002 10:20:00 +0800
- To: jeni@jenitennison.com, dareo@microsoft.com
- Cc: xmlschema-dev@w3.org
Jeni, Dare - thanks for that -
I've managed to get most of my schemas to validate using MSXML now,
by judicious adjustment of the order within choice groups.
But not all of them: here is another example that seems
to me /should/ work but MSXML just will not pass
- I use a <sequence> of two <choice> groups to restrict
a substitution group whose maxOccurs="unbounded".
MSXML insists "Invalid particle derivation by restriction".
Any ideas?
Here's the test schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xmml.ned.dem.csiro.au/my"
xmlns:my="http://xmml.ned.dem.csiro.au/my"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<!-- -->
<xs:element name="_Value" abstract="true"/>
<!-- pieces needed for compositing -->
<xs:complexType name="ValuePropertyType">
<xs:sequence>
<xs:element ref="my:_Value" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="valueProperty" type="my:ValuePropertyType"/>
<xs:element name="valueMember" type="my:ValuePropertyType"
substitutionGroup="my:valueProperty"/>
<xs:element name="lowerExclusive" type="my:ValuePropertyType"
substitutionGroup="my:valueMember"/>
<xs:element name="lowerInclusive" type="my:ValuePropertyType"
substitutionGroup="my:valueMember"/>
<xs:element name="upperInclusive" type="my:ValuePropertyType"
substitutionGroup="my:valueMember"/>
<xs:element name="upperExclusive" type="my:ValuePropertyType"
substitutionGroup="my:valueMember"/>
<!-- -->
<xs:complexType name="ValueCollectionType">
<xs:sequence>
<xs:element ref="my:valueMember" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!-- -->
<xs:complexType name="ValueRangeType">
<xs:complexContent>
<xs:restriction base="my:ValueCollectionType">
<xs:sequence>
<xs:choice>
<xs:element ref="my:lowerExclusive"/>
<xs:element ref="my:lowerInclusive"/>
</xs:choice>
<xs:choice>
<xs:element ref="my:upperInclusive"/>
<xs:element ref="my:upperExclusive"/>
</xs:choice>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
_____
[This mail represents part of a discussion of work in progress
and should not be used for any purpose without my permission.]
_____
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
> -----Original Message-----
> From: Jeni Tennison [mailto:jeni@jenitennison.com]
> Sent: Tuesday, 12 March 2002 7:29 PM
> To: Simon.Cox@csiro.au
> Cc: xmlschema-dev@w3.org; dareo@microsoft.com
> Subject: Re: Restricting a substitution group using <choice>
>
>
> 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 Thursday, 14 March 2002 21:29:17 UTC