<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="schema2xhtml.xsl" type="text/xsl"?>

<!-- XML Schema for JMRI Speedometer support                                   -->

<!-- $Id: speedometer.xsd 17977 2011-07-18 17:23:46Z zoo $ -->

<!-- This schema is part of JMRI. Copyright 2011.                           -->
<!--                                                                        -->
<!-- JMRI is free software; you can redistribute it and/or modify it under  -->
<!-- the terms of version 2 of the GNU General Public License as published  -->
<!-- by the Free Software Foundation. See the "COPYING" file for a copy     -->
<!-- of this license.                                                       -->
<!--                                                                        -->
<!-- JMRI is distributed in the hope that it will be useful, but WITHOUT    -->
<!-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  -->
<!-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License  -->
<!-- for more details.                                                      -->

<xs:schema xmlns:xs  ="http://www.w3.org/2001/XMLSchema"
           xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:docbook="http://docbook.org/ns/docbook"
           xmlns:jmri="http://jmri.org/xml/schema/JMRIschema"
           xsi:schemaLocation="
                http://jmri.org/xml/schema/JMRIschema http://jmri.org/xml/schema/JMRIschema.xsd
                http://docbook.org/ns/docbook http://jmri.org/xml/schema/docbook/DocBook.xsd
            "
           >

    <xs:include schemaLocation="http://jmri.org/xml/schema/types/general.xsd"/>
    <xs:import namespace='http://docbook.org/ns/docbook' schemaLocation='http://jmri.org/xml/schema/docbook/DocBook.xsd'/>

    <xs:element name="speedometer-config">
      <xs:annotation>
        <xs:documentation>
          This is the schema representing Speedometer information
        </xs:documentation>
        <xs:appinfo>
          <jmri:usingclass configurexml="false">jmri.jmrit.speedometer.SpeedometerFrame</jmri:usingclass>
        </xs:appinfo>
      </xs:annotation>
      <xs:complexType>
        <xs:sequence>
          <xs:element name="configuration" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                Speedometer configuration
              </xs:documentation>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:element name="useMetric" type="yesNoType" minOccurs="0" maxOccurs="1"/>
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
      </xs:complexType>

      <xs:simpleType name="sensorTypeListType">
          <xs:restriction base="xs:string">
              <xs:enumeration value="StartSensor"/>
              <xs:enumeration value="StopSensor1"/>
              <xs:enumeration value="StopSensor2"/>
          </xs:restriction>
      </xs:simpleType>

      <xs:simpleType name="sensorTriggerType">
          <xs:restriction base="xs:string">
              <xs:pattern value="entry|exit"/>
          </xs:restriction>
      </xs:simpleType>

      <xs:complexType name="SensorType">
        <xs:complexContent>
          <xs:sequence>
            <xs:element name="sensorName" type="xs:string" minOccurs="1" maxOccurs="1"/>
            <xs:element name="type" type="sensorTypeListType" minOccurs="1" maxOccurs="1"/>
            <xs:element name="trigger" type="sensorTriggerType" minOccurs="1" maxOccurs="1"/>
            <xs:element name="distance" type="xs:integer" minOccurs="0" maxOccurs="1"/>
          </xs:sequence>
        </xs:complexContent>
      </xs:complexType>

      <xs:complexType>
        <xs:sequence>
          <xs:element name="sensors" minOccurs="0" maxOccurs="1">
          <xs:annotation>
            <xs:documentation>
              ******** Required Sensor Table  **********
            </xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:sequence>
              <xs:element name="sensor" type="SensorType" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

