<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.ultimaker.com/material"
            xmlns="http://www.ultimaker.com/material" elementFormDefault="qualified">
    <!-- This XSD document is currently unused by CI, because lxml doesn't run on that server.
         If you plan to use it, make sure that it is still up-to-date. -->


    <xsd:element name="fdmmaterial">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="metadata">
                    <xsd:complexType>
                        <xsd:choice maxOccurs="unbounded">
                            <xsd:element name="name">
                                <xsd:complexType>
                                    <xsd:all>
                                        <xsd:element name="brand">
                                            <xsd:simpleType>
                                                <xsd:restriction base="xsd:string">
                                                    <xsd:minLength value="2"/>
                                                    <xsd:maxLength value="100"/>
                                                </xsd:restriction>
                                            </xsd:simpleType>
                                        </xsd:element>
                                        <xsd:element name="material">
                                            <xsd:simpleType>
                                                <xsd:restriction base="xsd:string">
                                                    <xsd:minLength value="2"/>
                                                    <xsd:maxLength value="100"/>
                                                </xsd:restriction>
                                            </xsd:simpleType>
                                        </xsd:element>
                                        <xsd:element name="color">
                                            <xsd:simpleType>
                                                <xsd:restriction base="xsd:string">
                                                    <xsd:minLength value="2"/>
                                                    <xsd:maxLength value="100"/>
                                                </xsd:restriction>
                                            </xsd:simpleType>
                                        </xsd:element>
                                        <xsd:element name="label" type="xsd:string" minOccurs="0"/>
                                    </xsd:all>
                                </xsd:complexType>
                            </xsd:element>
                            <xsd:element name="GUID">
                                <xsd:simpleType>
                                    <xsd:restriction base="xsd:string">
                                        <xsd:pattern
                                                value="[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}"/>
                                    </xsd:restriction>
                                </xsd:simpleType>
                            </xsd:element>

                            <xsd:element name="version" type="xsd:positiveInteger"/>
                            <xsd:element name="color_code">
                                <xsd:simpleType>
                                    <xsd:restriction base="xsd:string">
                                        <xsd:pattern value="(#[a-zA-F0-9]{6})|(RAL [0-9]{4})"/>
                                    </xsd:restriction>
                                </xsd:simpleType>
                            </xsd:element>

                            <xsd:element name="description" type="xsd:string" minOccurs="0"/>
                            <xsd:element name="adhesion_info" type="xsd:string" minOccurs="0"/>
                            <xsd:element name="instruction_link" type="url" minOccurs="0"/>
                            <xsd:element name="EAN" type="xsd:string" minOccurs="0"/>
                            <xsd:element name="TDS" type="url" minOccurs="0"/>
                            <xsd:element name="MSDS" type="url" minOccurs="0"/>
                            <xsd:element name="supplier" type="contact_info" minOccurs="0"/>
                            <xsd:element name="author" type="contact_info" minOccurs="0"/>
                            <!-- Specifically allow any settings from the Cura Namespace to be added here -->
                            <xsd:any minOccurs="0" namespace="http://www.ultimaker.com/cura" processContents ="lax"/>
                        </xsd:choice>
                    </xsd:complexType>
                </xsd:element>
                <xsd:element name="properties">
                    <xsd:complexType>
                        <xsd:all>
                            <xsd:element name="density" type="xsd:decimal" minOccurs="0"/>
                            <xsd:element name="diameter" type="xsd:decimal"/>
                            <xsd:element name="weight" type="xsd:decimal" minOccurs="0"/>
                        </xsd:all>
                    </xsd:complexType>
                </xsd:element>
                <xsd:element name="settings">
                    <xsd:complexType>
                        <xsd:sequence>
                            <!--  Permit any of these tags in any order in any number     -->
                            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                <xsd:element name="setting" minOccurs="0" maxOccurs="unbounded" type="setting"/>
                                <xsd:any namespace="http://www.ultimaker.com/cura" processContents="lax"/>
                                <xsd:element name="machine" maxOccurs="unbounded">
                                    <xsd:complexType>
                                        <xsd:sequence>
                                            <!--  Permit any of these tags in any order in any number     -->
                                            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                                <xsd:element name="machine_identifier" maxOccurs="unbounded">
                                                    <xsd:complexType>
                                                        <xsd:attribute name="manufacturer" type="xsd:string"
                                                                       use="required"/>
                                                        <xsd:attribute name="product" type="xsd:string" use="required"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                                <xsd:element name="hotend" maxOccurs="unbounded" minOccurs="0">
                                                    <xsd:complexType>
                                                        <xsd:sequence>
                                                            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                                                <xsd:element name="setting" type="setting"/>
                                                                <xsd:any namespace="http://www.ultimaker.com/cura"
                                                                         processContents="lax"/>
                                                            </xsd:choice>
                                                        </xsd:sequence>
                                                        <xsd:attribute name="id" type="xsd:string" use="required"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                                <xsd:element name="buildplate" maxOccurs="unbounded" minOccurs="0">
                                                    <xsd:complexType>
                                                        <xsd:sequence>
                                                            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                                                                <xsd:element name="setting" minOccurs="0"
                                                                             maxOccurs="unbounded"/>
                                                                <xsd:any namespace="http://www.ultimaker.com/cura"
                                                                         processContents="lax"/>
                                                            </xsd:choice>
                                                        </xsd:sequence>
                                                        <xsd:attribute name="id" type="xsd:string" use="required"/>
                                                    </xsd:complexType>
                                                </xsd:element>
                                                <xsd:element name="setting" minOccurs="0" maxOccurs="unbounded"
                                                             type="setting"/>
                                                <xsd:any namespace="http://www.ultimaker.com/cura"
                                                         processContents="lax"/>
                                            </xsd:choice>
                                        </xsd:sequence>
                                    </xsd:complexType>
                                </xsd:element>
                            </xsd:choice>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:attribute name="version" type="xsd:string" use="required" fixed="1.3"/>
        </xsd:complexType>
    </xsd:element>


    <xsd:complexType name="setting" mixed="true">
        <xsd:sequence>
            <xsd:element name="point" minOccurs="0" maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attribute name="flow" type="xsd:decimal" use="required"/>
                    <xsd:attribute name="temperature" type="xsd:decimal" use="required"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
        <xsd:attribute name="key" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="print temperature"/>
                    <xsd:enumeration value="heated bed temperature"/>
                    <xsd:enumeration value="maximum heated bed temperature"/>
                    <xsd:enumeration value="material bed adhesion temperature"/>
                    <xsd:enumeration value="heated chamber temperature"/>
                    <xsd:enumeration value="maximum heated chamber temperature"/>
                    <xsd:enumeration value="standby temperature"/>
                    <xsd:enumeration value="processing temperature graph"/>
                    <xsd:enumeration value="print cooling"/>
                    <xsd:enumeration value="retraction amount"/>
                    <xsd:enumeration value="retraction speed"/>
                    <xsd:enumeration value="hardware compatible"/>
                    <xsd:enumeration value="adhesion tendency"/>
                    <xsd:enumeration value="surface energy"/>
                    <xsd:enumeration value="relative extrusion"/>
                    <xsd:enumeration value="flow sensor detection margin"/>
                    <xsd:enumeration value="retract compensation"/>
                    <xsd:enumeration value="shrinkage percentage"/>
                    <xsd:enumeration value="anti ooze retract position"/>
                    <xsd:enumeration value="anti ooze retract speed"/>
                    <xsd:enumeration value="break preparation retracted position"/>
                    <xsd:enumeration value="break preparation speed"/>
                    <xsd:enumeration value="build volume temperature"/>
                    <xsd:enumeration value="break preparation temperature"/>
                    <xsd:enumeration value="break retracted position"/>
                    <xsd:enumeration value="break speed"/>
                    <xsd:enumeration value="break temperature"/>
                    <xsd:enumeration value="maximum park duration"/>
                    <xsd:enumeration value="no load move factor"/>
                    <xsd:enumeration value="flush purge speed"/>
                    <xsd:enumeration value="end of filament purge speed"/>
                    <xsd:enumeration value="flush purge length"/>
                    <xsd:enumeration value="end of filament purge length"/>
                    <xsd:enumeration value="break preparation position"/>
                    <xsd:enumeration value="break position"/>
                    <xsd:enumeration value="end of filament purge volume"/>
                    <xsd:enumeration value="end of print purge volume"/>
                    <xsd:enumeration value="pressure release dwell time"/>
                    <xsd:enumeration value="dwell time before break preparation move"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>


    <xsd:complexType name="contact_info">
        <xsd:sequence>
            <xsd:element name="organization" minOccurs="0" type="xsd:string"/>
            <xsd:element name="contact" minOccurs="0" type="xsd:string"/>
            <xsd:element name="email" minOccurs="0">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                        <xsd:pattern value="[^@]+@[^\.]+\..+"/>
                    </xsd:restriction>
                </xsd:simpleType>
            </xsd:element>
            <xsd:element name="phone" minOccurs="0" type="xsd:string"/>
            <xsd:element name="address" minOccurs="0" type="address_info"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="address_info">
        <xsd:sequence>
            <xsd:element name="street" minOccurs="0" type="xsd:string"/>
            <xsd:element name="city" minOccurs="0" type="xsd:string"/>
            <xsd:element name="region" minOccurs="0" type="xsd:string"/>
            <xsd:element name="zip" minOccurs="0" type="xsd:string"/>
            <xsd:element name="country" minOccurs="0" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name="url">
        <xsd:restriction base="xsd:string">
            <xsd:pattern
                    value="https?://(([a-z]+|[A-Z]+|[0-9]+|-+|_+)+\.)?([a-z]+|[A-Z]+|[0-9]+|-+|_+)+\.([a-z]+|[A-Z]+|[0-9]+|-+|_+)+(\.([a-z]+|[A-Z]+|[0-9]+|-+|_+)+)?((/([a-z]+|[A-Z]+|[0-9]+|-+|_+)+(/([a-z]+|[A-Z]+|[0-9]+|-+|_+)+)?)+)?/?"/>
        </xsd:restriction>
    </xsd:simpleType>

</xsd:schema>
