W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2004

I need help with some schema problems

From: Adam van den Hoven <AvandenHoven@cucbc.com>
Date: Mon, 5 Jan 2004 12:19:06 -0800
Message-ID: <24B5BB9D2057E546B6CFBAB6A46C974308F012@c2kmail1.cucbc.com>
To: <xmlschema-dev@w3.org>

Hi guys. 

I'm writing a very large schema (currently more that 100k spread across several files) and I've run into a hiccup that I can't seem to get my head around. 

I've included a schema that illustrates the problem I'm running into. 

Can someone tell me why the complexType "test4" generates the following validation error: 

derivation-ok-restriction.5.4.2: Error for type 'test4'. The particle of the type is not a valid restriction of the particle of the base.	 

I've validated this using OxygenXML (which I'm told uses Xerces). 

Now, intuitively, this makes absolutely no sense. The base type (test) allows any number of elements from the group "abs" and then an optional "d" element. The first 3 restrictions are all valid and define a sequence of "a" and "b" elements repeated some number of times followed by the "d". It seems that so long as exactly one of each is not specified, the restrictions will be valid. I can't see why having optional elements is valid but requiring them one is not. 

I want to say what is in test4 but I also want to keep all the abstractions. Any thoughts?


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element abstract="true" name="aba" type="xs:string"/>
    <xs:element abstract="true" name="abb" type="xs:int"/>
    <xs:element abstract="true" name="abc" type="xs:date"/>
    <xs:element name="a" substitutionGroup="aba" type="xs:string"/>
    <xs:element name="b" substitutionGroup="abb" type="xs:int"/>
    <xs:element name="c" substitutionGroup="abc" type="xs:date"/>
    <xs:element name="d" type="xs:anyURI"/>
    <xs:complexType name="test">
        <xs:sequence>
            <xs:group maxOccurs="unbounded" minOccurs="0" ref="abs"/>
            <xs:element minOccurs="0" ref="d"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="test1">
        <xs:complexContent>
            <xs:restriction base="test">
                <xs:sequence>
                    <xs:sequence minOccurs="0" maxOccurs="1">
                        <xs:element ref="a"/>
                        <xs:element ref="b"/>
                    </xs:sequence>
                    <xs:element ref="d"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="test2">
        <xs:complexContent>
            <xs:restriction base="test">
                <xs:sequence>
                    <xs:sequence minOccurs="0" maxOccurs="0">
                        <xs:element ref="a"/>
                        <xs:element ref="b"/>
                    </xs:sequence>
                    <xs:element ref="d"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="test3">
        <xs:complexContent>
            <xs:restriction base="test">
                <xs:sequence>
                    <xs:sequence minOccurs="1" maxOccurs="2">
                        <xs:element ref="a"/>
                        <xs:element ref="b"/>
                    </xs:sequence>
                    <xs:element ref="d"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="test4">
        <xs:complexContent>
            <xs:restriction base="test">
                <xs:sequence>
                    <xs:sequence minOccurs="1" maxOccurs="1">
                        <xs:element ref="a"/>
                        <xs:element ref="b"/>
                    </xs:sequence>
                    <xs:element ref="d"/>
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:group name="abs">
        <xs:choice>
            <xs:element ref="aba"/>
            <xs:element ref="abb"/>
            <xs:element ref="abc"/>
        </xs:choice>
    </xs:group>
</xs:schema>
Received on Monday, 5 January 2004 15:19:07 GMT

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