<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="RequiredText">
    <xs:restriction base="xs:string">
      <xs:whiteSpace value="collapse"/>
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="YesNo">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Yes"/>
      <xs:enumeration value="No"/>
      <xs:enumeration value="yes"/>
      <xs:enumeration value="no"/>
      <xs:enumeration value="YES"/>
      <xs:enumeration value="NO"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="TransactionType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="sale"/>
      <xs:enumeration value="seasonal rentals"/>
      <xs:enumeration value="vacation rentals"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="OrientationList">
    <xs:restriction base="xs:string">
      <xs:pattern value="[ ]*(N|NE|E|SE|S|SW|W|NW)[ ]*(,[ ]*(N|NE|E|SE|S|SW|W|NW)[ ]*)*"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="HttpsUrl">
    <xs:restriction base="xs:anyURI">
      <xs:pattern value="https://.+"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="properties">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="agency" minOccurs="0">
          <xs:complexType><xs:all>
            <xs:element name="name" type="xs:string" minOccurs="0"/>
            <xs:element name="email" type="xs:string" minOccurs="0"/>
            <xs:element name="phone" type="xs:string" minOccurs="0"/>
            <xs:element name="nationality" type="xs:string" minOccurs="0"/>
            <xs:element name="address" type="xs:string" minOccurs="0"/>
            <xs:element name="zipcode" type="xs:string" minOccurs="0"/>
            <xs:element name="city" type="xs:string" minOccurs="0"/>
            <xs:element name="website" type="xs:anyURI" minOccurs="0"/>
            <xs:element name="logo" type="xs:anyURI" minOccurs="0"/>
          </xs:all></xs:complexType>
        </xs:element>

        <xs:element name="property" minOccurs="1" maxOccurs="unbounded">
          <xs:complexType><xs:all>
            <xs:element name="reference" type="RequiredText"/>
            <xs:element name="last_update" type="xs:date"/>
            <xs:element name="contact_phone" type="xs:string" minOccurs="0"/>
            <xs:element name="type_transaction" type="TransactionType"/>
            <xs:element name="type" type="RequiredText"/>
            <xs:element name="latitude" type="xs:decimal" minOccurs="0"/>
            <xs:element name="longitude" type="xs:decimal" minOccurs="0"/>
            <xs:element name="zip_code" type="xs:string" minOccurs="0"/>
            <xs:element name="city" type="RequiredText"/>
            <xs:element name="area" type="xs:string" minOccurs="0"/>
            <xs:element name="country" type="RequiredText"/>
            <xs:element name="price" type="xs:decimal"/>
            <xs:element name="currency" type="xs:string" minOccurs="0"/>
            <xs:element name="price_visible" type="YesNo" minOccurs="0"/>
            <xs:element name="area_useful" type="xs:decimal" minOccurs="0"/>
            <xs:element name="area_plot" type="xs:decimal" minOccurs="0"/>
            <xs:element name="year" type="xs:gYear" minOccurs="0"/>
            <xs:element name="floors" type="xs:integer" minOccurs="0"/>
            <xs:element name="rooms" type="xs:integer" minOccurs="0"/>
            <xs:element name="bedrooms" type="xs:integer" minOccurs="0"/>
            <xs:element name="bathroom" type="xs:integer" minOccurs="0"/>
            <xs:element name="shower_room" type="xs:integer" minOccurs="0"/>
            <xs:element name="garages" type="xs:integer" minOccurs="0"/>
            <xs:element name="terraces" type="xs:integer" minOccurs="0"/>
            <xs:element name="balconies" type="xs:integer" minOccurs="0"/>
            <xs:element name="orientation" type="OrientationList" minOccurs="0"/>
            <xs:element name="kitchen" type="xs:integer" minOccurs="0"/>
            <xs:element name="kitchen_fitted" type="xs:integer" minOccurs="0"/>
            <xs:element name="kitchen_US" type="xs:integer" minOccurs="0"/>
            <xs:element name="kitchen_independent" type="xs:integer" minOccurs="0"/>
            <xs:element name="garden" type="YesNo" minOccurs="0"/>
            <xs:element name="air_conditioning" type="YesNo" minOccurs="0"/>
            <xs:element name="lift" type="YesNo" minOccurs="0"/>
            <xs:element name="parking" type="xs:integer" minOccurs="0"/>
            <xs:element name="swimming_pool" type="YesNo" minOccurs="0"/>
            <xs:element name="cellar" type="YesNo" minOccurs="0"/>
            <xs:element name="wifi" type="YesNo" minOccurs="0"/>
            <xs:element name="gym" type="YesNo" minOccurs="0"/>
            <xs:element name="beds" type="xs:integer" minOccurs="0"/>
            <xs:element name="pets" type="YesNo" minOccurs="0"/>
            <xs:element name="price_min_vac" type="xs:decimal" minOccurs="0"/>
            <xs:element name="price_max_vac" type="xs:decimal" minOccurs="0"/>
            <xs:element name="sea_view" type="YesNo" minOccurs="0"/>
            <xs:element name="waterfront" type="YesNo" minOccurs="0"/>

            <xs:element name="distances" minOccurs="0">
              <xs:complexType><xs:all>
                <xs:element name="beach" type="xs:integer" minOccurs="0"/>
                <xs:element name="shops" type="xs:integer" minOccurs="0"/>
                <xs:element name="airport" type="xs:integer" minOccurs="0"/>
                <xs:element name="station" type="xs:integer" minOccurs="0"/>
                <xs:element name="city_center" type="xs:integer" minOccurs="0"/>
              </xs:all></xs:complexType>
            </xs:element>

            <xs:element name="title_en" type="xs:string" minOccurs="0"/>
            <xs:element name="text_en" type="xs:string" minOccurs="0"/>
            <xs:element name="title_fr" type="xs:string" minOccurs="0"/>
            <xs:element name="text_fr" type="xs:string" minOccurs="0"/>
            <xs:element name="title_it" type="xs:string" minOccurs="0"/>
            <xs:element name="text_it" type="xs:string" minOccurs="0"/>
            <xs:element name="title_es" type="xs:string" minOccurs="0"/>
            <xs:element name="text_es" type="xs:string" minOccurs="0"/>
            <xs:element name="title_pt" type="xs:string" minOccurs="0"/>
            <xs:element name="text_pt" type="xs:string" minOccurs="0"/>
            <xs:element name="title_de" type="xs:string" minOccurs="0"/>
            <xs:element name="text_de" type="xs:string" minOccurs="0"/>
            <xs:element name="title_nl" type="xs:string" minOccurs="0"/>
            <xs:element name="text_nl" type="xs:string" minOccurs="0"/>
            <xs:element name="title_ru" type="xs:string" minOccurs="0"/>
            <xs:element name="text_ru" type="xs:string" minOccurs="0"/>

            <xs:element name="photos">
              <xs:complexType><xs:sequence>
                <xs:element name="photo" type="xs:anyURI" minOccurs="1" maxOccurs="30"/>
              </xs:sequence></xs:complexType>
            </xs:element>
            <xs:element name="plans" minOccurs="0">
              <xs:complexType><xs:sequence>
                <xs:element name="plan" type="HttpsUrl" minOccurs="1" maxOccurs="5"/>
              </xs:sequence></xs:complexType>
            </xs:element>
            <xs:element name="video_url" type="xs:anyURI" minOccurs="0"/>
            <xs:element name="virtual_tour_url" type="xs:anyURI" minOccurs="0"/>
            <xs:element name="ener_class" type="xs:string" minOccurs="0"/>
            <xs:element name="ener_value" type="xs:decimal" minOccurs="0"/>
            <xs:element name="gas_class" type="xs:string" minOccurs="0"/>
            <xs:element name="gas_value" type="xs:decimal" minOccurs="0"/>
            <xs:element name="co-ownership_status" type="YesNo" minOccurs="0"/>
            <xs:element name="condominium_fees" type="xs:decimal" minOccurs="0"/>
            <xs:element name="num_units" type="xs:integer" minOccurs="0"/>
            <xs:element name="fees_purchaser" type="xs:decimal" minOccurs="0"/>
          </xs:all></xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>