<!--
Link:
    - url
    - relation
    - media-type

SupplierDatabase
    Supplier
        - url
        - id (short name, used for UI)

ExchangeRateDatabase
    ExchangeRate
        - from
        - to
        - rate

PartListFile
  PartList
  Pricing (also used directly on a Part)

PartListFile is used for
* BOM (schema export)
* downloading facts and prices from suppliers
* Creating orders from sets of available part lists

TODO: rename 'id' to 'url'.
-->
<xs:schema
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://purl.org/ee/bom-file"
        xmlns="http://purl.org/ee/bom-file">

    <xs:attribute name="id" type="xs:string"/>

    <xs:element name="bom-file" type="BomFile"/>
    <xs:element name="part" type="Part"/>

    <xs:complexType name="BomFile">
        <xs:sequence>
            <xs:element name="parts" type="PartList" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Part">
        <!-- TODO: add links, references to product page,data sheets. -->
        <xs:sequence>
            <xs:element name="schema-reference" type="xs:string"/>
            <xs:element name="part-type" type="xs:anyURI"/>
            <xs:element name="part-numbers" type="PartNumberList"/>
            <xs:element name="distributor-info" type="DistributorInfo"/>
            <xs:element name="facts" type="FactList"/>
            <xs:element name="price-breaks" type="PriceBreakList"/>
        </xs:sequence>
        <xs:attribute ref="id" use="required"/>
    </xs:complexType>

    <xs:complexType name="PartList">
        <xs:sequence>
            <xs:element name="part" type="Part" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="PartNumber">
        <xs:sequence>
            <xs:element name="value" type="xs:string"/>
            <xs:element name="distributor" type="xs:anyURI"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="PartNumberList">
        <xs:sequence>
            <xs:element name="part-number" type="PartNumber" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Fact">
        <xs:sequence>
            <xs:element name="key" type="xs:anyURI"/>
            <xs:element name="label" type="xs:string"/>
            <xs:element name="value" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="FactList">
        <xs:sequence>
            <xs:element name="fact" type="Fact" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="DistributorInfo">
        <xs:sequence>
            <xs:element name="state" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="Amount">
        <xs:attribute name="value" use="required"/>
        <xs:attribute name="currency"/>
    </xs:complexType>

    <xs:complexType name="PriceBreak">
        <xs:sequence>
            <xs:element name="quantity" type="xs:anyURI"/>
            <xs:element name="amount" type="Amount"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="PriceBreakList">
        <xs:sequence>
            <xs:element name="price-break" type="PriceBreak" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>