<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="market" type="marketType"/>

    <xs:complexType name="marketType">
        <xs:sequence>
            <xs:element name="items" type="itemsType"/>
            <xs:element name="places" type="placesType"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="placesType">
        <xs:sequence>
            <xs:element name="place" type="placeType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="servicesType">
        <xs:sequence>
            <xs:element name="service" type="serviceType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="itemsType">
        <xs:sequence>
            <xs:element name="group" type="groupType" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="item" type="itemType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="groupType">
        <xs:sequence>
            <xs:element name="item" type="itemType" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="type" type="GROUP_TYPE" use="required"/>
    </xs:complexType>

    <xs:simpleType name="GROUP_TYPE">
        <xs:restriction base="xs:string">
            <xs:enumeration value="MARKET"/>
            <xs:enumeration value="SHIP"/>
            <xs:enumeration value="OUTFIT"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="itemType">
        <xs:attribute name="id" type="xs:ID" use="required"/>
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="illegalf" type="xs:string" use="optional"/>
        <xs:attribute name="illegalg" type="xs:string" use="optional"/>
        <xs:attribute name="legalf" type="xs:string" use="optional"/>
        <xs:attribute name="legalg" type="xs:string" use="optional"/>
    </xs:complexType>

    <xs:complexType name="placeType" mixed="true">
        <xs:sequence>
            <xs:element name="vendor" type="vendorType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="faction" type="FACTION" use="optional"/>
        <xs:attribute name="government" type="GOVERNMENT" use="optional"/>
        <xs:attribute name="control" type="POWER_STATE" use="optional"/>
        <xs:attribute name="power" type="POWER" use="optional"/>
        <xs:attribute name="x" type="xs:double" use="optional"/>
        <xs:attribute name="y" type="xs:double" use="optional"/>
        <xs:attribute name="z" type="xs:double" use="optional"/>
    </xs:complexType>

    <xs:complexType name="vendorType" mixed="true">
        <xs:sequence>
            <xs:element name="services" type="servicesType"/>
            <xs:element name="offer" type="offerType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="faction" type="FACTION" use="optional"/>
        <xs:attribute name="government" type="GOVERNMENT" use="optional"/>
        <xs:attribute name="type" type="STATION_TYPE" use="optional"/>
        <xs:attribute name="economic1" type="ECONOMIC_TYPE" use="optional"/>
        <xs:attribute name="economic2" type="ECONOMIC_TYPE" use="optional"/>
        <xs:attribute name="distance" type="xs:double"/>
        <xs:attribute name="modified" type="xs:dateTime" use="optional"/>
    </xs:complexType>

    <xs:complexType name="serviceType">
        <xs:attribute name="type" type="SERVICE_TYPE" use="required"/>
    </xs:complexType>

    <xs:simpleType name="SERVICE_TYPE">
        <xs:restriction base="xs:string">
            <xs:enumeration value="MARKET"/>
            <xs:enumeration value="BLACK_MARKET"/>
            <xs:enumeration value="REFUEL"/>
            <xs:enumeration value="REPAIR"/>
            <xs:enumeration value="MUNITION"/>
            <xs:enumeration value="OUTFIT"/>
            <xs:enumeration value="SHIPYARD"/>
            <xs:enumeration value="MEDIUM_LANDPAD"/>
            <xs:enumeration value="LARGE_LANDPAD"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="offerType">
        <xs:attribute name="item" type="xs:IDREFS" use="required"/>
        <xs:attribute name="type" type="OFFER_TYPE" use="required"/>
        <xs:attribute name="price" type="xs:double" use="required"/>
        <xs:attribute name="count" type="xs:long" use="required"/>
    </xs:complexType>

    <xs:simpleType name="OFFER_TYPE">
        <xs:restriction base="xs:string">
            <xs:enumeration value="SELL"/>
            <xs:enumeration value="BUY"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="FACTION">
        <xs:restriction base="xs:string">
            <xs:enumeration value="FEDERATION"/>
            <xs:enumeration value="EMPIRE"/>
            <xs:enumeration value="ALLIANCE"/>
            <xs:enumeration value="INDEPENDENT"/>
            <xs:enumeration value="NONE"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="GOVERNMENT">
        <xs:restriction base="xs:string">
            <xs:enumeration value="ANARCHY"/>
            <xs:enumeration value="COLONY"/>
            <xs:enumeration value="COMMUNISM"/>
            <xs:enumeration value="CONFEDERACY"/>
            <xs:enumeration value="COOPERATIVE"/>
            <xs:enumeration value="CORPORATE"/>
            <xs:enumeration value="DEMOCRACY"/>
            <xs:enumeration value="DICTATORSHIP"/>
            <xs:enumeration value="FEUDAL"/>
            <xs:enumeration value="IMPERIAL"/>
            <xs:enumeration value="PATRONAGE"/>
            <xs:enumeration value="PRISON_COLONY"/>
            <xs:enumeration value="THEOCRACY"/>
            <xs:enumeration value="NONE"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="POWER_STATE">
        <xs:restriction base="xs:string">
            <xs:enumeration value="CONTROL"/>
            <xs:enumeration value="EXPLOITED"/>
            <xs:enumeration value="EXPANSION"/>
            <xs:enumeration value="CONTESTED"/>
            <xs:enumeration value="HEADQUARTERS"/>
            <xs:enumeration value="NONE"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="POWER">
        <xs:restriction base="xs:string">
            <xs:enumeration value="DUVAL"/>
            <xs:enumeration value="DELAINE"/>
            <xs:enumeration value="LAVIGNY_DUVAL"/>
            <xs:enumeration value="PATREUS"/>
            <xs:enumeration value="MAHON"/>
            <xs:enumeration value="WINTERS"/>
            <xs:enumeration value="YONG_RUI"/>
            <xs:enumeration value="ANTAL"/>
            <xs:enumeration value="HUDSON"/>
            <xs:enumeration value="TORVAL"/>
            <xs:enumeration value="NONE"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="STATION_TYPE">
        <xs:restriction base="xs:string">
            <xs:enumeration value="STARPORT"/>
            <xs:enumeration value="CORIOLIS_STARPORT"/>
            <xs:enumeration value="OCELLUS_STARPORT"/>
            <xs:enumeration value="ORBIS_STARPORT"/>
            <xs:enumeration value="OUTPOST"/>
            <xs:enumeration value="CIVILIAN_OUTPOST"/>
            <xs:enumeration value="COMMERCIAL_OUTPOST"/>
            <xs:enumeration value="INDUSTRIAL_OUTPOST"/>
            <xs:enumeration value="MILITARY_OUTPOST"/>
            <xs:enumeration value="MINING_OUTPOST"/>
            <xs:enumeration value="SCIENTIFIC_OUTPOST"/>
            <xs:enumeration value="UNSANCTIONED_OUTPOST"/>
            <xs:enumeration value="PLANETARY_PORT"/>
            <xs:enumeration value="PLANETARY_OUTPOST"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="ECONOMIC_TYPE">
        <xs:restriction base="xs:string">
            <xs:enumeration value="AGRICULTURE"/>
            <xs:enumeration value="EXTRACTION"/>
            <xs:enumeration value="HIGH_TECH"/>
            <xs:enumeration value="INDUSTRIAL"/>
            <xs:enumeration value="MILITARY"/>
            <xs:enumeration value="REFINERY"/>
            <xs:enumeration value="SERVICE"/>
            <xs:enumeration value="TERRAFORMING"/>
            <xs:enumeration value="TOURISM"/>
            <xs:enumeration value="COLONY"/>
            <xs:enumeration value="NONE"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>