Restriction validation (3.9.6)

I'm trying to interpret the rules in 3.9.6 and have some problems with
Occurrence Range OK
(http://www.w3.org/TR/xmlschema-1/#range-ok ) rules.

Here is the example.
...
<complexType name="B">
    <sequence> <!-- S1B -->
        <element name="annotation" minOccurs="0" type="string"/>
        <sequence minOccurs="2" maxOccurs="3"> <!-- S2B -->
            <element name="e0" minOccurs="0"  type="string"/>
            <element name="e1" minOccurs="2" maxOccurs="3"   type="string"/>
        </sequence>
    </sequence>
</complexType>

Couple examples of valid XML fragments for type B:

<annotation>First fragment</annotation>
<e0>e0(B) First occurrence of the Sequence</e0>
<e1>e1(B) #1-1</e1><e1>e1(B) #1-2</e1>
<e0>e0(B) Second occurrence of the Sequence</e0>
<e1>e1(B) #2-1</e1><e1>e1(B) #2-2</e1>
...

<!-- Second fragment -->
<e1>e1(B) #1-1</e1><e1>e1(B) #1-2</e1><e1>e1(B) #1-3</e1>
<e1>e1(B) #2-1</e1><e1>e1(B) #2-2</e1><e1>e1(B) #2-3</e1>
<e1>e1(B) #3-1</e1><e1>e1(B) #3-2</e1><e1>e1(B) #3-3</e1>

Both XML fragments are obviously valid against <complexType name="B">.
Looking at the second fragment one can utilize the restricted complexType:

<complexType name="R">
    <complexContent>
        <restriction base="B">
            <sequence><!-- S1R -->
                <element name="e1" minOccurs="4" maxOccurs="9"/>
            </sequence>
        </restriction>
    </complexContent>
</complexType>
...

So far it's all pretty trivial. Now let's try to apply the rules from 3.9.6
literally:

1. Checking S1R against S1B using "All:All,Sequence:Sequence --  Recurs"
rule
    (see http://www.w3.org/TR/xmlschema-1/#rcase-Recurse):
    1. Checking if S1R occurrence range is a valid restriction of S1B
occurrence range
        using http://www.w3.org/TR/xmlschema-1/#range-ok:
        1. minOccurs(S1R) >= minOccurs(S1B)? (1 >=  1) == true: OK
        2. maxOccurs(S1R) <= maxOccurs(S1B)? (1 <= 1) == true: OK
    2. Functional mapping. There are two particles in S1B: annotation and
S2B
        1. Checking if e1(R) is a valid restriction of annotation(B) using
            "Elt:Elt -- NameAndTypeOK" rule (see
            http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK ):
            1. The declaration's {name}s are the same: NO
        2. Checking if e1(R) is a valid restriction of S2B using
"Elt:All/Choice/Sequence
            -- RecurseAsIfGroup"
            (see http://www.w3.org/TR/xmlschema-1/#rcase-RecurseAsIfGroup):
            1. Creating a new S2R from <element name="e1" minOccurs="4"
maxOccurs="9"/>:
                <sequence><element name="e1" minOccurs="4"
maxOccurs="9"/></sequence>
            2. Checking newly created S2R against S2B using
"All:All,Sequence:Sequence
                --  Recurs".
                1. Checking if S2R occurrence range is a valid restriction
of S2B occurrence range
                    1. minOccurs(S2R) >= minOccurs(S2B)? (1 >= 2) == false:
BAD RESTRICTION

OOPS...
I could continue on but every time I'll get BAD RESTRICTION trying to apply
"Occurrence Range OK" rules literally.

Should I check not the "Occurrence Range OK"  but "Effective Total Range OK"
(http://www.w3.org/TR/xmlschema-1/#cos-seq-range )?
(minETR(S2R) >= minETR(S2B)? (1*4 >= 2*2) == true: OK.)

Or my interpretation of "Occurrence Range OK" is wrong.

Even if I'll use Effective Total Range OK it's not defined for elements.
Therefore, the check for [Elt:Elt -- NameAndTypeOK-3: R's occurrence range
is a valid restriction of B's occurrence range as defined by Occurrence
Range OK] will fail after few more steps (see
http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK ).



Thanks in advance for any suggestion,
Michael

Received on Saturday, 16 June 2001 18:51:04 UTC