<?xml version="1.0" encoding="UTF-8"?>
<!--
  NoirEstates listing feed — XML Schema (XSD 1.0).

  One <noirestates> root element with one <listing> per property. Field order
  follows this schema and the example feed (noirestates-example.xml).

  Required on every listing: reference, type, intent, price, city, latitude,
  longitude. All prices are in EUR. Coordinates must fall inside Cyprus. The
  full field guide lives at https://noirestates.com/import-guide.

  Note: our importer is more lenient than this schema (element order does not
  matter to it, and `type` accepts common labels like "Villa" or "Office").
  Anything that validates against this schema will import; the schema is here
  to help you produce a correct feed.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

  <xs:simpleType name="intentType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="sale"/>
      <xs:enumeration value="rent"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="latitudeType">
    <xs:restriction base="xs:decimal">
      <xs:minInclusive value="34.2"/>
      <xs:maxInclusive value="35.9"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="longitudeType">
    <xs:restriction base="xs:decimal">
      <xs:minInclusive value="31.9"/>
      <xs:maxInclusive value="34.9"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="positiveDecimal">
    <xs:restriction base="xs:decimal">
      <xs:minExclusive value="0"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="noirestates">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="listing" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="reference" type="xs:string"/>
              <xs:element name="type" type="xs:string"/>
              <xs:element name="subtype" type="xs:string" minOccurs="0"/>
              <xs:element name="intent" type="intentType"/>
              <xs:element name="price" type="positiveDecimal"/>
              <xs:element name="currency" type="xs:string" minOccurs="0"/>
              <xs:element name="city" type="xs:string"/>
              <xs:element name="district" type="xs:string" minOccurs="0"/>
              <xs:element name="neighborhood" type="xs:string" minOccurs="0"/>
              <xs:element name="latitude" type="latitudeType"/>
              <xs:element name="longitude" type="longitudeType"/>
              <xs:element name="bedrooms" type="xs:nonNegativeInteger" minOccurs="0"/>
              <xs:element name="bathrooms" type="xs:nonNegativeInteger" minOccurs="0"/>
              <xs:element name="internal_area_sqm" type="positiveDecimal" minOccurs="0"/>
              <xs:element name="plot_area_sqm" type="positiveDecimal" minOccurs="0"/>
              <xs:element name="title" type="xs:string" minOccurs="0"/>
              <xs:element name="description" type="xs:string" minOccurs="0"/>
              <xs:element name="contact_phone" type="xs:string" minOccurs="0"/>
              <xs:element name="contact_whatsapp" type="xs:string" minOccurs="0"/>
              <!-- Developers only: the slug of one of your NoirEstates developments;
                   the unit appears on its development page. See /import-guide. -->
              <xs:element name="project_slug" type="xs:string" minOccurs="0"/>
              <xs:element name="image" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
