<?xml version="1.0" encoding="utf-8" ?>
<!--
/*   Copyright 2004 The Apache Software Foundation
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *  limitations under the License.
 */
-->


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:element name="DerivedTypesTestRoot">
        <xsd:complexType>
            <xsd:sequence>
<!--                <xsd:element ref="ExtensionBaseTypeElem"/> -->
                <xsd:element ref="ExtensionDerivedComplexContentTypeElem"/>

<!--                <xsd:element ref="ExtensionBaseMixedContentTypElem"/> -->
                <xsd:element ref="ExtensionDerivedMixedContentTypeElem"/>

<!--                <xsd:element ref="RestrictionSimpleContentBaseTypeElem"/> -->
                <xsd:element ref="RestrictionSimpleContentDerivedTypeElem"/>

                <xsd:element ref="RestrictionBaseComplexContentTypeElem"/>
                <xsd:element ref="RestrictionDerivedComplexContentTypeElem"/>

                <xsd:element ref="RestrictionBaseMixedContentTypeElem" />
                <xsd:element ref="RestrictionDerivedMixedContentTypeElem" />

                <xsd:element ref="RestrictionBaseEmptyContentTypeElem" />
                <xsd:element ref="RestrictionDerivedEmptyContentTypeElem" />

            </xsd:sequence>

        </xsd:complexType>
    </xsd:element>


    <xsd:element name="ExtensionBaseTypeElem" type="ExtensionBaseType"/>
    <xsd:element name="ExtensionDerivedComplexContentTypeElem" type="ExtensionDerivedComplexContentType"/>

    <xsd:element name="ExtensionBaseMixedContentTypElem" type="ExtensionBaseMixedContentType"/>
    <xsd:element name="ExtensionDerivedMixedContentTypeElem" type="ExtensionDerivedMixedContentType"/>

    <xsd:element name="RestrictionSimpleContentBaseTypeElem" type="RestrictionSimpleContentBaseType"/>
    <xsd:element name="RestrictionSimpleContentDerivedTypeElem" type="RestrictionSimpleContentDerivedType"/>

    <xsd:element name="RestrictionBaseComplexContentTypeElem" type="RestrictionBaseComplexContentType"/>
    <xsd:element name="RestrictionDerivedComplexContentTypeElem" type="RestrictionDerivedComplexContentType"/>

    <xsd:element name="RestrictionBaseMixedContentTypeElem" type="RestrictionBaseMixedContentType"/>
    <xsd:element name="RestrictionDerivedMixedContentTypeElem" type="RestrictionDerivedMixedContentType"/>

    <xsd:element name="RestrictionBaseEmptyContentTypeElem" type="RestrictionBaseEmptyContentType"/>
    <xsd:element name="RestrictionDerivedEmptyContentTypeElem" type="RestrictionDerivedEmptyContentType"/>

    <!-- restriction testing...-->
    <!-- complex type, simple content : headerType from mails_types_added.xsd -->

    <!-- complex type, complex content -->
    <xsd:complexType name="ExtensionBaseType">
        <xsd:sequence>
            <xsd:element name="ExtBaseTypeElem1" type="xsd:string"/>
            <xsd:element name="ExtBaseTypeElem2" type="xsd:integer"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="ExtensionBaseType2">
        <xsd:sequence>
            <xsd:element name="ExtBaseTypeElem3" type="xsd:string"/>
            <xsd:element name="ExtBaseTypeElem4" type="xsd:integer"/>
        </xsd:sequence>
    </xsd:complexType>


    <xsd:complexType name="ExtensionDerivedComplexContentType">
        <xsd:complexContent>
            <!-- change the base type ...
            <xsd:extension base="ExtensionBaseType">
            -->
            <xsd:extension base="ExtensionBaseType2">
                <xsd:choice maxOccurs="unbounded">
                    <xsd:element name="ExtDerivedTypeElem1" type="CarEngineType"/>
                    <xsd:element name="ExtDerivedTypeElem2" type="xsd:string"/>
                </xsd:choice>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <!-- complex type, mixed  content -->

    <xsd:complexType name="ExtensionDerivedMixedContentType" mixed="true">
        <xsd:complexContent>
            <!-- change base type
            <xsd:extension base="ExtensionBaseMixedContentType">
            -->
            <xsd:extension base="ExtensionBaseMixedContentType2">
                <xsd:sequence>
                    <xsd:element name="ExtDerivedMixedElem1" type="xsd:string" />
                </xsd:sequence>
                <xsd:attribute name="ExtDerivedMixedAttr" type="xsd:integer"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:complexType name="ExtensionBaseMixedContentType" mixed="true">
        <xsd:sequence>
            <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
            <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="ExtensionBaseMixedContentType2" mixed="true">
        <xsd:sequence>
            <xsd:element name="ExtBaseMixedElem3" type="xsd:string" />
            <xsd:element name="ExtBaseMixedElem4" type="CarEngineType" />
        </xsd:sequence>
    </xsd:complexType>



    <xsd:complexType name="CarEngineType">
        <xsd:choice>
            <xsd:element name="Valves" type="xsd:integer"/>
            <xsd:element name="Capacity" type="xsd:decimal"/>
        </xsd:choice>
    </xsd:complexType>

    <!-- derived types restriction testing -->
    <!-- 1. complex types : simple content -->
    <xsd:complexType name="RestrictionSimpleContentBaseType">
        <xsd:simpleContent>
            <xsd:extension base="xsd:integer">
                <xsd:attribute name="RestrictionSimpleContentBaseAttr1" type="xsd:string" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <!-- restricts the base with range and making the attribute required -->
    <xsd:complexType name="RestrictionSimpleContentDerivedType">
        <xsd:simpleContent>
            <xsd:restriction base="RestrictionSimpleContentBaseType">
                <xsd:minInclusive value="2" />
                <xsd:maxExclusive value="6" />
                <xsd:attribute name= "RestrictionSimpleContentBaseAttr1" type="xsd:string" use="required" />
            </xsd:restriction>
        </xsd:simpleContent>
    </xsd:complexType>

    <!-- 2. complex content -->
    <xsd:complexType name="RestrictionBaseComplexContentType">
            <xsd:sequence>
                <xsd:element name="RestrictionBaseElem1" type="xsd:string" />
                <xsd:element name="RestrictionBaseElem2" type="xsd:integer" />
                <xsd:element name="RestrictionBaseElem3" type="xsd:integer"  minOccurs="0"/>
                <xsd:element name="RestrictionBaseElem4" type="xsd:string"  minOccurs="0"/>
            </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="RestrictionBaseComplexContentType2">
            <xsd:sequence>
                <xsd:element name="RestrictionBaseElem5" type="xsd:string" />
                <xsd:element name="RestrictionBaseElem6" type="xsd:string" />
            </xsd:sequence>
    </xsd:complexType>



    <xsd:complexType name="RestrictionDerivedComplexContentType">
        <xsd:complexContent>
            <!-- modify base
            <xsd:restriction base="RestrictionBaseComplexContentType2">
            -->
            <xsd:restriction base="RestrictionBaseComplexContentType">
                <xsd:sequence>
                    <xsd:element name="RestrictionBaseElem1" type="xsd:string"/>
                    <xsd:element name="RestrictionBaseElem2" type="xsd:integer"/>
                </xsd:sequence>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <!-- 3. mixed content -->
    <xsd:complexType name="RestrictionBaseMixedContentType">
        <xsd:sequence>
            <xsd:element name="ResBaseMixedElem1" type="xsd:string" minOccurs="0"/>
            <xsd:element name="ResBaseMixedElem2" type="CarEngineType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="RestrictionBaseMixedContentType2">
        <xsd:sequence>
            <xsd:element name="ResBaseMixedElem3" type="xsd:string" minOccurs="0"/>
            <xsd:element name="ResBaseMixedElem4" type="CarEngineType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>


    <xsd:complexType name="RestrictionDerivedMixedContentType">
        <xsd:complexContent>
            <!-- change base type
            <xsd:restriction base="RestrictionBaseMixedContentType">
            -->
            <xsd:restriction base="RestrictionBaseMixedContentType2">
                <xsd:sequence>
                    <xsd:element name="ResBaseMixedElem3" type="xsd:string" />
                </xsd:sequence>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <!-- empty content -->
    <xsd:complexType name="RestrictionBaseEmptyContentType">
        <xsd:attribute name="RestrictionBaseEmptyContentAttr1" type="xsd:integer" />
    </xsd:complexType>

    <xsd:complexType name="RestrictionDerivedEmptyContentType">
        <xsd:complexContent>
            <xsd:restriction base="RestrictionBaseEmptyContentType">
                <xsd:attribute name="RestrictionBaseEmptyContentAttr1" type="xsd:short" />
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>


</xsd:schema>
