Alex Milowski wrote:
> I've been wrestling with this bug and now I realize that I get the
> correct answer
> out of Xerces. For a substitution group, you need everything in the
> group to have the
> same "base" type. That means you can always use 'anyType' for the base
> of the
> substitution group. Unfortunately, this doesn't seem to work.
>
> Attached is a schema that Xerces finds OK but XMLMind does not.
XMLmind implements this:
---
Schema Component Constraint: Type Derivation OK (Simple)
For a simple type definition (call it D, for derived) to be validly
derived from a simple type definition (call this B, for base) given a
subset of {extension, restriction, list, union} (of which only
restriction is actually relevant) one of the following must be true:
1 They are the same type definition.
2 All of the following must be true:
2.1 restriction is not in the subset, or in the {final} of its own {base
type definition};
2.2 One of the following must be true:
2.2.1 D's ?base type definition? is B.
2.2.2 D's ?base type definition? is not the ?simple ur-type definition?
and is validly derived from B given the subset, as defined by this
constraint.
2.2.3 D's {variety} is list or union and B is the ?simple ur-type
definition?.
2.2.4 B's {variety} is union and D is validly derived from a type
definition in B's {member type definitions} given the subset, as defined
by this constraint.
---
But the XMLschema 1.0 spec *Errata* now says this:
---
Schema Component Constraint: Type Derivation OK (Simple)
For a simple type definition (call it D, for derived) to be validly
derived from a type definition (call this B, for base) given a subset of
{extension, restriction, list, union} (of which only restriction is
actually relevant) one of the following must be true:
1 They are the same type definition.
2 All of the following must be true:
2.1 restriction is not in the subset, or in the {final} of its own {base
type definition};
2.2 One of the following must be true:
2.2.1 D's ?base type definition? is B.
2.2.2 D's ?base type definition? is not the ?ur-type definition? and is
validly derived from B given the subset, as defined by this constraint.
2.2.3 D's {variety} is list or union and B is the ?simple ur-type
definition?.
2.2.4 B's {variety} is union and D is validly derived from a type
definition in B's {member type definitions} given the subset, as defined
by this constraint.
---
Therefore, we'll update XMLmind schema validator (which correctly
implements the original spec and, according to this original spec, was
right in rejecting your schema).
As a temporary workaround, you could use this schema:
---
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="urn:IDN+cde.berkeley.edu:milowski:examples:20040211:us"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:u="urn:IDN+cde.berkeley.edu:milowski:examples:20040211:us"
xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty">
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="u:unit"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element abstract="true" name="unit" type="xs:anyType"></xs:element>
<xs:element name="single-unit" substitutionGroup="u:unit"
type="u:SingleUnitType"></xs:element>
<xs:complexType name="SingleUnitType" mixed="true" />
<xs:element name="unit-range" substitutionGroup="u:unit"
type="u:RangeUnitCourseType"></xs:element>
<xs:complexType name="RangeUnitCourseType">
<xs:sequence>
<xs:element form="qualified" name="start" type="xs:int"></xs:element>
<xs:element form="qualified" name="end" type="xs:int"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="unit-choices" substitutionGroup="u:unit"
type="u:ChoiceUnitCourseType"></xs:element>
<xs:complexType name="ChoiceUnitCourseType">
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="u:unit"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
---
According to current XMLmind schema validator it is valid and it can be
used to validate this instance:
---
<test xmlns="urn:IDN+cde.berkeley.edu:milowski:examples:20040211:us">
<unit-range><start>1</start><end>2</end></unit-range>
<unit-choices>
<unit-range><start>1</start><end>2</end></unit-range>
<unit-range><start>3</start><end>4</end></unit-range>
</unit-choices>
<single-unit>foo</single-unit>
<single-unit>bar</single-unit>
</test>
---