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

<!-- Schema for JMRI locomotive support.          -->

<!-- $Id: roster.xsd 18040 2011-07-25 14:34:40Z kevin-dickerson $ -->

<!-- This schema is part of JMRI. Copyright 2009, 2010.                     -->
<!--                                                                        -->
<!-- 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.                                                      -->


<!-- Not in Venetian blind form                                       -->
<!-- Need annotations                                                 -->
<!-- Attributes need to get types right esp. for enumerated           -->
<!-- Attributes need REQUIRED/IMPLIED                                 -->

<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:element name="locomotive-config">
    <xs:annotation>
        <xs:documentation>
          This is the schema representing the over-all loco element
        </xs:documentation>
        <xs:appinfo>
            <jmri:usingclass configurexml="false">jmri.jmrit.roster.LocoFile</jmri:usingclass>
        </xs:appinfo>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="locomotive" type="LocomotiveType" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
    <xs:complexType name="LocomotiveType">
      <xs:sequence>
        <xs:element name="dateUpdated" minOccurs="0" maxOccurs="1">
            <xs:annotation>
                <xs:documentation>
                  This is an unchecked, unparsed field intended to hold a system-local date.
                </xs:documentation>
            </xs:annotation>
        </xs:element>
        
        <xs:element name="decoder" type="DecoderType" minOccurs="1" maxOccurs="1" />
        
        <xs:element name="locoaddress" type="LocoAddressType" minOccurs="0" maxOccurs="1" />
        
        <xs:element name="functionlabels" type="FunctionLabelType" minOccurs="0" maxOccurs="1" />
        
        <xs:element name="attributepairs" type="AttributePairsType" minOccurs="0" maxOccurs="unbounded" />
        
        <xs:element name="values" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
            <xs:element name="decoderDef" minOccurs="0" maxOccurs="1">
                <xs:complexType>
                <xs:sequence>
                <xs:element name="varValue" minOccurs="0" maxOccurs="unbounded">
                  <xs:complexType>
                    <xs:attribute name="item" type="xs:string" use="required"/>
                    <xs:attribute name="value" type="xs:string" use="required"/> <!--String as all the speed table values are written in one string-->
                  </xs:complexType>
                </xs:element>
                </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="CVvalue" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:attribute name="name" type="xs:integer" use="required"/>
                <xs:attribute name="value" use="required">
                  <xs:simpleType>
                    <xs:restriction base="xs:integer">
                      <xs:minInclusive value="0"/>
                      <xs:maxInclusive value="255"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
            <xs:element name="indexedCVvalue" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:attribute name="name" type="xs:decimal" use="required"/>
                <xs:attribute name="piCv" type="xs:integer" use="required"/>
                <xs:attribute name="piVal" type="xs:integer" use="required"/>
                <xs:attribute name="siCv" type="xs:integer" use="required"/>
                <xs:attribute name="siVal" type="xs:integer" use="required"/>
                <xs:attribute name="iCv" type="xs:integer" use="required"/>
                <xs:attribute name="value" use="required">
                  <xs:simpleType>
                    <xs:restriction base="xs:integer">
                      <xs:minInclusive value="0"/>
                      <xs:maxInclusive value="255"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
              </xs:complexType>
            </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      
        <xs:attribute name="id" type="xs:string" use="required"/>
        <xs:attribute name="dccAddress" type="xs:string"/> <!-- deprecated -->
        <xs:attribute name="fileName" type="xs:string"/>
        <xs:attribute name="imageFilePath" type="xs:string"/>
        <xs:attribute name="iconFilePath" type="xs:string"/>
        <xs:attribute name="URL" type="xs:string"/>
        <xs:attribute name="IsShuntingOn" type="xs:string"/>
        <xs:attribute name="groupName" type="xs:string"/>
        <xs:attribute name="roadName" type="xs:string"/>
        <xs:attribute name="roadNumber" type="xs:string"/>
        <xs:attribute name="mfg" type="xs:string"/>
        <xs:attribute name="owner" type="xs:string"/>
        <xs:attribute name="model" type="xs:string"/>
        <xs:attribute name="comment" type="xs:string"/>
        <xs:attribute name="maxSpeed" type="xs:float">
        <xs:annotation><xs:documentation>
            maximum speed as a fraction from 0 to 1.0
        </xs:documentation></xs:annotation>
        </xs:attribute>
          
    </xs:complexType>
    
    <xs:complexType name="LocoAddressType"><xs:sequence>
      <xs:element name="dcclocoaddress" minOccurs="1" maxOccurs="1">
        <xs:complexType>
          <xs:attribute name="number" type="xs:integer" use="required"/>
          <xs:attribute name="longaddress" type="yesNoType" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence></xs:complexType>
    
  <xs:complexType name="AttributePairsType"><xs:sequence>
      <xs:element name="keyvaluepair" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType><xs:sequence>
            <xs:element name="key" minOccurs="1" maxOccurs="1"/>
            <xs:element name="value" minOccurs="1" maxOccurs="1"/>
        </xs:sequence></xs:complexType>
      </xs:element>
  </xs:sequence></xs:complexType>
  
  <xs:complexType name="DecoderType">
    <xs:attribute name="family" type="xs:string" use="required"/>
    <xs:attribute name="model" type="xs:string" use="required"/>
    <xs:attribute name="comment" type="xs:string"/>
  </xs:complexType>
  

  <xs:complexType name="FunctionLabelType">
    <xs:sequence>
      <xs:element name="functionlabel" minOccurs="0" maxOccurs="unbounded">
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:attribute name="num" use="required">
                  <xs:simpleType>
                    <xs:restriction base="xs:integer">
                      <xs:minInclusive value="0"/>
                      <xs:maxInclusive value="28"/>
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
              <xs:attribute name="lockable" type="trueFalseType"/>
              <xs:attribute name="functionImage" type="xs:string"/>
              <xs:attribute name="functionImageSelected" type="xs:string"/>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

</xs:schema>

