W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2002

Error in the schema for schemas?

From: Stefan Wachter <Stefan.Wachter@gmx.de>
Date: Sun, 11 Aug 2002 11:49:34 -0400 (EDT)
To: xmlschema-dev@w3.org
Message-ID: <19186.1029080950@www3.gmx.net>




Hi all,

I tried to validate the schema for schemas and encountered a problem
regarding particle restrictions. It amounts to that the definition of the
simpleRestrictionType seems incorrect with respect to the "Particle Valid
(Restriction)" constraint.

In essence the problem is caused by the fact that the two content models (of
the base type and the restricted type) are structurally different. In order
to validate the restriction it must be valid to replace a choice group by one
of its particles in the restricted content model.

In order to explain the problem in more detail I include the corresponding
content models:

1. The content model of the restrictionType that is the base type of
simpleRestrictionType:

<sequence minOccurs="1" maxOccurs="1">
    <sequence minOccurs="1" maxOccurs="1">
        <element name="annotation"/>
    </sequence>
    <sequence minOccurs="1" maxOccurs="1">
        <choice minOccurs="1" maxOccurs="1">
            <choice minOccurs="0" maxOccurs="1">
                <element name="group"/>
                <element name="all"/>
                <element name="choice"/>
                <element name="sequence"/>
            </choice>
            <sequence minOccurs="0" maxOccurs="1">
                <element name="simpleType"/>
                <choice minOccurs="0" maxOccurs="unbounded">
                    <element name="minExclusive"/>
                    <element name="minInclusive"/>
                    <element name="maxExclusive"/>
                    <element name="maxInclusive"/>
                    <element name="totalDigits"/>
                    <element name="fractionDigits"/>
                    <element name="length"/>
                    <element name="minLength"/>
                    <element name="maxLength"/>
                    <element name="enumeration"/>
                    <element name="whiteSpace"/>
                    <element name="pattern"/>
                </choice>
            </sequence>
        </choice>
        <sequence minOccurs="1" maxOccurs="1">
            <choice minOccurs="0" maxOccurs="unbounded">
                <element name="attribute"/>
                <element name="attributeGroup"/>
            </choice>
            <element name="anyAttribute"/>
        </sequence>
    </sequence>
</sequence>

After removing pointless groups the result is the content model B:

<sequence minOccurs="1" maxOccurs="1">
    <element name="annotation"/>
    <choice minOccurs="1" maxOccurs="1">
        <choice minOccurs="0" maxOccurs="1">
            <element name="group"/>
            <element name="all"/>
            <element name="choice"/>
            <element name="sequence"/>
        </choice>
        <sequence minOccurs="0" maxOccurs="1">
            <element name="simpleType"/>
            <choice minOccurs="0" maxOccurs="unbounded">
                <element name="minExclusive"/>
                <element name="minInclusive"/>
                <element name="maxExclusive"/>
                <element name="maxInclusive"/>
                <element name="totalDigits"/>
                <element name="fractionDigits"/>
                <element name="length"/>
                <element name="minLength"/>
                <element name="maxLength"/>
                <element name="enumeration"/>
                <element name="whiteSpace"/>
                <element name="pattern"/>
            </choice>
        </sequence>
    </choice>
    <choice minOccurs="0" maxOccurs="unbounded">
        <element name="attribute"/>
        <element name="attributeGroup"/>
    </choice>
    <element name="anyAttribute"/>
</sequence>

Next there is the content model of the simpleRestrictionType as it is
defined in the schema for schemas:

<sequence minOccurs="1" maxOccurs="1">
    <element name="annotation"/>
    <sequence minOccurs="0" maxOccurs="1">
        <element name="simpleType"/>
        <choice minOccurs="0" maxOccurs="unbounded">
            <element name="minExclusive"/>
            <element name="minInclusive"/>
            <element name="maxExclusive"/>
            <element name="maxInclusive"/>
            <element name="totalDigits"/>
            <element name="fractionDigits"/>
            <element name="length"/>
            <element name="minLength"/>
            <element name="maxLength"/>
            <element name="enumeration"/>
            <element name="whiteSpace"/>
            <element name="pattern"/>
        </choice>
    </sequence>
    <sequence minOccurs="1" maxOccurs="1">
        <choice minOccurs="0" maxOccurs="unbounded">
            <element name="attribute"/>
            <element name="attributeGroup"/>
        </choice>
        <element name="anyAttribute"/>
    </sequence>
</sequence>

Removing pointless groups in this model yields the content model R:

<sequence minOccurs="1" maxOccurs="1">
    <element name="annotation"/>
    <sequence minOccurs="0" maxOccurs="1">
        <element name="simpleType"/>
        <choice minOccurs="0" maxOccurs="unbounded">
            <element name="minExclusive"/>
            <element name="minInclusive"/>
            <element name="maxExclusive"/>
            <element name="maxInclusive"/>
            <element name="totalDigits"/>
            <element name="fractionDigits"/>
            <element name="length"/>
            <element name="minLength"/>
            <element name="maxLength"/>
            <element name="enumeration"/>
            <element name="whiteSpace"/>
            <element name="pattern"/>
        </choice>
    </sequence>
    <choice minOccurs="0" maxOccurs="unbounded">
        <element name="attribute"/>
        <element name="attributeGroup"/>
    </choice>
    <element name="anyAttribute"/>
</sequence>

Compare the content model B and R clearly shows the problem: R is a
restriction of B because B contain a choise group that contains among another choice
group a sequence group. Now, in R is this choice replaced by this sequence.

Yet the algorithm for validating particles can not cope with this situation.
When validating a sequence as a restriction of a choice the case that the
choice is simply replaced by one of its particles is not considered.

What can we do? Is only the schema for schemas incorrect or should the
constraint for particle validations extended to cope with such cases?

--Stefan
Received on Tuesday, 13 August 2002 12:00:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT