Message:

   The following issue has been closed.

   Resolver: Sandy Gao
       Date: Wed, 19 May 2004 8:16 AM

It seems to me that the only outstanding question is whether something like the 
following is valid:

Base: (E1){2}
Derived: (E2, E1)
where E2 is in E1's substitution group. (i.e. E2 substitutes E1)

Mike Boos' final patch validates this, but my understanding of the spec is that it's 
invalid.

Following the rules in 3.9.6 of the structure spec, turning sub groups into choices,
base becomes: (E1|E2){2}
and derived: (E2, (E1|E2))

Following the big table to the "MapAndSum" constraint. It requires that each particle 
in "derived" matches a particle in "base", which implies that (E1|E2) in "derived" has 
to match either E1 or E2. This is clearly forbidden by the table.

Closing this bug since it's invalid. My sympathy to this "obviously valid" schema. (We 
are trying to improve restriction constraints in future versions of XML Schema.)
---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESJ-922

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESJ-922
    Summary: incorrect validation of substitution groups with restriction
       Type: Bug

     Status: Closed
 Resolution: INCOMPLETE

    Project: Xerces2-J
 Components: 
             XML Schema Structures
   Versions:
             2.6.2

   Assignee: Sandy Gao
   Reporter: Eric J Schwarzenbach

    Created: Mon, 22 Mar 2004 5:56 AM
    Updated: Wed, 19 May 2004 8:16 AM
Environment: Operating System: Windows XP
Platform: PC

Description:
I'm seeing some oddities with the validation of certain constructs using
restriction and substitution groups, 
that intuitively do not make sense, and which I cannot account for by the spec.

I'm including simple test schemas, whose name I'll refer to in the below; what
I'm seeing are the following:

All my examples start with a base element and its global complex type which is a
sequence of another element (1,n), also with global type (see base1-n.xsd). From
that I derive types from both these types by restriction, and define elements
from those types, declaring those elements to be in the substitution group of
the elements defined as the base type. What I end up with is a structure that is
a restricted form of the base, using different element names.

This works, mostly, however I get errors in several cases in which as far as I
can tell from the spec, I should not. In particular I get a RecurseLax.2 error
if my derived sequence is a single derived element (1,n) (see
deriv_1-n_simple.xsd). I can make this go away by inserting a superfluous choice
group between the sequence and the element, making the choice (1,n) and the
element (1,1) (see deriv_1-n_extra_choice.xsd). This kind of makes sense given
the spec's requiring substitution groups be treated as choices in just this
manner, however the validator surely shouldn't require derivations to mimic this
implicit structure explicitly.


Another case is where instead of that sequence of one derived element (1,n) I
substitute several derived elements, each (1,1) and the base element again (1,1)
(see deriv-3seq-plus.xsd). This gives me a MapAndSum.1 error. Without the base
element it validates fine. If instead of the base element, I use another element
declare as the type the base type itself (not a derived type) it also validates.
However if the last element is (1,n) (derived or base) it fails with that
MapAndSum.1. I don't include all the example schemas for these...to save space I
let whoever tries this make the alterations themselves.

Example schemas:

base1-N.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xml.wrycan.com/test/restr_sub";
xmlns:test="http://xml.wrycan.com/test/restr_sub";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
attributeFormDefault="unqualified">
    <xs:element name="outer">
        <xs:complexType>
            <xs:complexContent>
                <xs:extension base="test:outerType"/>
            </xs:complexContent>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="outerType">
        <xs:sequence>
            <xs:element ref="test:inner" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="inner" type="test:innerType"/>
    <xs:simpleType name="innerType">
        <xs:restriction base="xs:string"/>
    </xs:simpleType>
</xs:schema>

deriv_1-n_simple.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xml.wrycan.com/test/restr_sub";
xmlns:test="http://xml.wrycan.com/test/restr_sub"; elementFormDefault="qualified"
attributeFormDefault="unqualified">
    <xs:include schemaLocation="base-1toN.xsd"/>
    <xs:element name="dervOuter" type="test:dervOuterType"/>
    <xs:element name="dervInnerA" type="test:dervInnerType"
substitutionGroup="test:inner"/>
    <xs:simpleType name="dervInnerType">
        <xs:restriction base="test:innerType">
            <xs:pattern value="-?[0-9]{1,3}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="dervOuterType">
        <xs:complexContent>
            <xs:restriction base="test:outerType">
                <xs:sequence>
                    <xs:element ref="test:dervInnerA" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

deriv_1-n_extra_choice.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xml.wrycan.com/test/restr_sub";
xmlns:test="http://xml.wrycan.com/test/restr_sub";
xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
attributeFormDefault="unqualified">
    <xs:include schemaLocation="base-1toN.xsd"/>
    <xs:element name="dervOuter" type="test:dervOuterType"/>
    <xs:element name="dervInnerA" type="test:dervInnerType"
substitutionGroup="test:inner"/>
    <xs:simpleType name="dervInnerType">
        <xs:restriction base="test:innerType">
            <xs:pattern value="-?[0-9]{1,3}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="dervOuterType">
        <xs:complexContent>
            <xs:restriction base="test:outerType">
                <xs:sequence>
                    <xs:choice maxOccurs="unbounded">
                        <xs:element ref="test:dervInnerA"/>
                    </xs:choice>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

deriv-3seq-plus.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://xml.wrycan.com/test/restr_sub";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:test="http://xml.wrycan.com/test/restr_sub"; elementFormDefault="qualified"
attributeFormDefault="unqualified">
    <xs:include schemaLocation="base-1toN.xsd"/>
    <xs:element name="dervOuter" type="test:dervOuterType"/>
    <xs:element name="dervInnerA" type="test:dervInnerType"
substitutionGroup="test:inner"/>
    <xs:element name="dervInnerB" type="test:dervInnerType"
substitutionGroup="test:inner"/>
    <xs:element name="dervInnerC" type="test:dervInnerType"
substitutionGroup="test:inner"/>
    <xs:simpleType name="dervInnerType">
        <xs:restriction base="test:innerType">
            <xs:pattern value="-?[0-9]{1,3}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="dervOuterType">
        <xs:complexContent>
            <xs:restriction base="test:outerType">
                <xs:sequence>
                    <xs:element ref="test:dervInnerA"/>
                    <xs:element ref="test:dervInnerB"/>
                    <xs:element ref="test:dervInnerC"/>
                    <xs:element ref="test:inner"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:element name="dervInnerSameType" type="test:innerType"
substitutionGroup="test:inner"/>
</xs:schema>


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to