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

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

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

<!-- This file contains definitions for both Logix and Conditionals, -->
<!-- since they are so intimately coupled -->

<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:complexType name="LogixManagerType">
      <xs:annotation>
        <xs:documentation>
          Define the XML stucture for storing the contents of a LogixManager implementation.
        </xs:documentation>
        <xs:appinfo>
            <jmri:usingclass configurexml="true">jmri.managers.configurexml.DefaultLogixManagerXml</jmri:usingclass>
        </xs:appinfo>
      </xs:annotation>
      <xs:sequence>
        
        <xs:element name="logix" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="comment" type="commentType" minOccurs="0" maxOccurs="unbounded"/>
              <xs:element name="logixConditional" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:attribute name="systemName" type="systemNameType" use="required" />
                  <xs:attribute name="order" type="xs:nonNegativeInteger" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="systemName" type="systemNameType" use="required" />
            <xs:attribute name="userName" type="userNameType" />
            <xs:attribute name="enabled" type="yesNoType" />
          </xs:complexType>
        </xs:element>
            
      </xs:sequence>
      <xs:attribute name="class" type="classType" use="required"/>
    </xs:complexType>

    <xs:complexType name="ConditionalManagerType">
      <xs:annotation>
        <xs:documentation>
          Define the XML stucture for storing the contents of a ConditionalManager implementation.
        </xs:documentation>
        <xs:appinfo>
            <jmri:usingclass configurexml="true">jmri.managers.DefaultConditionalManagerXml</jmri:usingclass>
        </xs:appinfo>
      </xs:annotation>
      <xs:sequence>
        
        <xs:element name="conditional" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="conditionalStateVariable" minOccurs="0" maxOccurs="unbounded" >
                <xs:complexType>
                  <xs:attribute name="operator" type="xs:integer" use="required" />
                  <xs:attribute name="negated" type="yesNoType" default="no" />
                  <xs:attribute name="type" type="xs:integer" use="required" />
                  <xs:attribute name="systemName"  use="required">
                    <xs:simpleType>
                      <xs:annotation><xs:documentation>Allow empty string and single space, emitted by old code</xs:documentation></xs:annotation>
                      <xs:union>
                        <xs:simpleType>
                          <xs:restriction base="systemNameType" />
                        </xs:simpleType>
                        <xs:simpleType>
                          <xs:restriction base="xs:string">
                            <xs:enumeration value=" "/>
                            <xs:enumeration value=""/>
                          </xs:restriction>  
                        </xs:simpleType>
                      </xs:union>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="dataString" type="xs:string" use="required" />
                  <xs:attribute name="num1" type="xs:integer" use="required" />
                  <xs:attribute name="num2" type="xs:integer" use="required" />
                  <xs:attribute name="triggersCalc" type="yesNoType" default="yes" />
                </xs:complexType>
              </xs:element>
              <xs:element name="conditionalAction" minOccurs="0" maxOccurs="unbounded" >
                <xs:complexType>
                  <xs:attribute name="option" type="xs:integer" use="required" />
                  <xs:attribute name="type" type="xs:integer" use="required" />
                  <xs:attribute name="systemName"  use="required">
                    <xs:simpleType>
                      <xs:annotation><xs:documentation>Allow single space, emitted by old code</xs:documentation></xs:annotation>
                      <xs:union>
                        <xs:simpleType>
                          <xs:restriction base="systemNameType" />
                        </xs:simpleType>
                        <xs:simpleType>
                          <xs:restriction base="xs:string">
                            <xs:enumeration value=" "/>
                          </xs:restriction>  
                        </xs:simpleType>
                      </xs:union>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attribute name="data" type="xs:string" use="required" />
                  <xs:attribute name="delay" type="xs:integer" use="required" />
                  <xs:attribute name="string" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="systemName" type="systemNameType" use="required"/>
            <xs:attribute name="userName" type="nullUserNameType" /> 
            <xs:attribute name="antecedent" type="xs:string" />
            <xs:attribute name="logicType" type="xs:integer" />
            <xs:attribute name="triggerOnChange" type="xs:string" />
          </xs:complexType>
        </xs:element>
            
      </xs:sequence>
      <xs:attribute name="class" type="classType" use="required"/>
    </xs:complexType>

</xs:schema>

