<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
    targetNamespace="http://services.mobile.de/schema/search"
    xmlns:search="http://services.mobile.de/schema/search"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:ad="http://services.mobile.de/schema/ad"
    xmlns:error="http://services.mobile.de/schema/common/error-1.0"
    elementFormDefault="qualified">

    <xs:import namespace="http://services.mobile.de/schema/ad" schemaLocation="ad-1.0.xsd"/>
    <xs:import namespace="http://services.mobile.de/schema/common/error-1.0" schemaLocation="common/error-1.0.xsd"/>

    <xs:element name="result">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="ad:ad" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="total" use="required" type="xs:int"/>
            <xs:attribute name="page-size" use="required" type="xs:int"/>
            <xs:attribute name="current-page" use="required" type="xs:int"/>
            <xs:attribute name="max-pages" use="required" type="xs:int"/>
        </xs:complexType>
    </xs:element>

    <xs:element name="search-result">
        <xs:annotation>
            <xs:documentation>The ad-search-result including some metadata, probably warnings and the ads (for this
                page).
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="total" type="xs:int">
                    <xs:annotation>
                        <xs:documentation>The total number of results.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="page-size" type="xs:int">
                    <xs:annotation>
                        <xs:documentation>The number of results per page.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="current-page" type="xs:int">
                    <xs:annotation>
                        <xs:documentation>The current page number.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="max-pages" type="xs:int">
                    <xs:annotation>
                        <xs:documentation>The total number of results-pages.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element ref="error:errors" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>A list of non fatal errors related to this search request e.g. invalid or
                            deprecated search parameters. If this list is present then the search result might not be as
                            intended by the client, so always check that this not present.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="ads">
                    <xs:annotation>
                        <xs:documentation>The ad results (of this page).</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element ref="ad:ad" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="event-type">
        <xs:restriction base="xs:string">
            <xs:enumeration value="AD_CREATE_OR_UPDATE">
                <xs:annotation>
                    <xs:documentation></xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="AD_DELETE">
                <xs:annotation>
                    <xs:documentation></xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="ERROR">
                <xs:annotation>
                    <xs:documentation></xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="event">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="event-type" type="search:event-type" minOccurs="0"/>
                <xs:element name="ad-key" type="xs:token" minOccurs="0"/>
                <xs:element ref="ad:ad" minOccurs="0"/>
                <xs:element ref="error:errors" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>

</xs:schema>