<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <xsd:include schemaLocation="baseTypes.xsd" />

    <xsd:element name="nodes" type="nodesType">
        <xsd:key name="nodeKey">
            <xsd:selector xpath="node"/>
            <xsd:field xpath="@id"/>
        </xsd:key>
    </xsd:element>

    <xsd:complexType name="nodesType">
        <xsd:sequence>
            <xsd:element name="location" type="locationType" minOccurs="0" maxOccurs="1"/>
            <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:element name="node" type="nodeType"/>
                <xsd:element name="delete" type="deleteType"/>
                <xsd:element name="join" type="joinType"/>
                <xsd:element name="joinExclude" type="joinExcludeType"/>
            </xsd:choice>
        </xsd:sequence>
        <xsd:attribute name="version" use="optional">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:pattern value="\d+.\d+"></xsd:pattern>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="nodeType">
        <xsd:attribute name="id" type="xsd:string" use="required"/>
        <xsd:attribute name="x" type="xsd:float" use="optional"/>
        <xsd:attribute name="y" type="xsd:float" use="optional"/>
        <xsd:attribute name="z" type="xsd:float" use="optional"/>
        <xsd:attribute name="type" use="optional">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="traffic_light"/>
                    <xsd:enumeration value="right_before_left"/>
                    <xsd:enumeration value="priority"/>
                    <xsd:enumeration value="dead_end"/>
                    <xsd:enumeration value="unregulated"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="tl" type="xsd:string" use="optional"/>
        <xsd:attribute name="tlType" type="tlTypeType" use="optional"/>
    </xsd:complexType>

    <xsd:complexType name="deleteType">
        <xsd:attribute name="id" type="xsd:string" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="joinType">
        <xsd:attribute name="nodes" type="xsd:string" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="joinExcludeType">
        <xsd:attribute name="nodes" type="xsd:string" use="required"/>
    </xsd:complexType>

</xsd:schema>
