<?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"/>

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

    <!-- complex type, complex content -->
    <!-- commented out for testing
    <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="ExtensionDerivedComplexContentType">
        <xsd:complexContent>
            <xsd:extension base="ExtensionBaseType">
                <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>
            <xsd:extension base="ExtensionBaseMixedContentType">
                <xsd:sequence>
                    <xsd:element name="ExtDerivedMixedElem1" type="xsd:string" />
                </xsd:sequence>
                <xsd:attribute name="ExtDerivedMixedAttr" type="xsd:integer"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <!-- commented out for testing
    <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="ExtensionBaseType2">
        <xsd:sequence>
            <xsd:element name="ExtBaseTypeElem3" type="xsd:string"/>
            <xsd:element name="ExtBaseTypeElem4" type="xsd:integer"/>
        </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 -->
    <!-- commented out for testing ..
    <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="RestrictionDerivedComplexContentType">
        <xsd:complexContent>
            <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 -->
    <!-- commented out for testing ..
    <xsd:complexType name="RestrictionBaseMixedContentType">
        <xsd:sequence>
            <xsd:element name="ExtBaseMixedElem1" type="xsd:string" minOccurs="0"/>
            <xsd:element name="ExtBaseMixedElem2" type="CarEngineType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    -->

    <xsd:complexType name="RestrictionDerivedMixedContentType">
        <xsd:complexContent>
            <xsd:restriction base="RestrictionBaseMixedContentType">
                <xsd:sequence>
                    <xsd:element name="ExtBaseMixedElem1" type="xsd:string" />
                </xsd:sequence>
            </xsd:restriction>
        </xsd:complexContent>
    </xsd:complexType>

    <!-- empty content -->
    <!-- commented out for testing ..
    <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>
