<?xml version="1.0" encoding="utf-8"?>

<!-- ============================================================
     An XML Schema Definition for the Routino tagging rules XML format

     Part of the Routino routing software.
     ============================================================
     This file Copyright 2010-2011 Andrew M. Bishop

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU Affero General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.
     ============================================================ -->

<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <!-- The top level Routino tagging rules -->

  <xsd:element name="routino-tagging" type="RoutinoTaggingType"/>

  <xsd:complexType name="RoutinoTaggingType">
    <xsd:sequence>
      <xsd:element name="node"        type="NodeType"/>
      <xsd:element name="way"         type="WayType"/>
      <xsd:element name="relation"    type="RelationType"/>
    </xsd:sequence>
  </xsd:complexType>

  <!-- The second level node, way and relation tagging rules -->

  <xsd:complexType name="NodeType">
    <xsd:sequence>
      <xsd:element name="if" type="IfType" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="WayType">
    <xsd:sequence>
      <xsd:element name="if" type="IfType" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="RelationType">
    <xsd:sequence>
      <xsd:element name="if" type="IfType" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <!-- The if tag and its contents -->

  <xsd:complexType name="IfType">
    <xsd:sequence>
      <xsd:element name="set"      type="SetType"      minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="unset"    type="UnsetType"    minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="output"   type="OutputType"   minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="logerror" type="LogErrorType" minOccurs="0" maxOccurs="1"/>
    </xsd:sequence>
    <xsd:attribute name="k" type="xsd:string"/>
    <xsd:attribute name="v" type="xsd:string"/>
  </xsd:complexType>

  <xsd:complexType name="SetType">
    <xsd:attribute name="k" type="xsd:string"/>
    <xsd:attribute name="v" type="xsd:string"/>
  </xsd:complexType>

  <xsd:complexType name="UnsetType">
    <xsd:attribute name="k" type="xsd:string"/>
  </xsd:complexType>

  <xsd:complexType name="OutputType">
    <xsd:attribute name="k" type="xsd:string"/>
    <xsd:attribute name="v" type="xsd:string"/>
  </xsd:complexType>

  <xsd:complexType name="LogErrorType">
    <xsd:attribute name="k" type="xsd:string"/>
    <xsd:attribute name="v" type="xsd:string"/>
  </xsd:complexType>

</xsd:schema>

