<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <include href="common.rng"/>
  <start>
    <ref name="JobState"/>
  </start>
  <!--
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#
                        Mobyle JobState Definition                #
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#
  -->
  <define name="JobState">
    <element name="jobState">
      <interleave>
        <!-- this part describes the elements specific to the file that stores job information -->
        <element name="name">
          <data type="anyURI"/>
        </element>
        <!-- name is the url of the program invoked to run the job -->
        <element name="host">
          <data type="anyURI"/>
        </element>
        <!-- host is the host server of the job -->
        <element name="id">
          <data type="anyURI"/>
        </element>
        <!-- id is the job identifier -->
        <element name="date">
          <data type="token"/>
        </element>
        <!-- date on which the job has been submitted on the server -->
        <element name="status">
          <interleave>
            <element name="value">
              <choice>
                <value>building</value>
                <value>submitted</value>
                <value>pending</value>
                <value>running</value>
                <value>finished</value>
                <value>error</value>
                <value>killed</value>
                <value>hold</value>
                <value>finishing</value>
              </choice>
            </element>
            <optional>
              <element name="message">
                <text/>
              </element>
            </optional>
          </interleave>
        </element>
        <optional>
          <ref name="Email"/>
        </optional>
        <optional>
          <element name="sessionKey">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="workflowId">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="data">
            <interleave>
              <zeroOrMore>
                <ref name="Input"/>
              </zeroOrMore>
              <zeroOrMore>
                <ref name="Output"/>
              </zeroOrMore>
            </interleave>
          </element>
        </optional>
        <choice>
          <interleave>
            <optional>
              <!-- this is the "program specific" part of the "job state" -->
              <element name="paramFiles">
                <a:documentation>parameter files</a:documentation>
                <zeroOrMore>
                  <ref name="File"/>
                </zeroOrMore>
              </element>
            </optional>
            <optional>
              <element name="commandLine">
                <a:documentation>generated command line</a:documentation>
                <text/>
              </element>
            </optional>
          </interleave>
          <!-- this is the "workflow specific" part of the "job state" -->
          <element name="jobLink">
            <interleave>
              <attribute name="taskRef">
                <data type="anyURI"/>
              </attribute>
              <attribute name="jobId">
                <data type="anyURI"/>
              </attribute>
            </interleave>
          </element>
        </choice>
      </interleave>
    </element>
  </define>
  <define name="Input">
    <element name="input">
      <interleave>
        <ref name="Parameter"/>
        <choice>
          <interleave>
            <ref name="File"/>
            <optional>
              <element name="fmtProgram">
                <text/>
              </element>
            </optional>
            <optional>
              <element name="formattedFile">
                <ref name="FileContent"/>
              </element>
            </optional>
          </interleave>
          <element name="value">
            <text/>
          </element>
        </choice>
      </interleave>
    </element>
  </define>
  <define name="Output">
    <element name="output">
      <interleave>
        <ref name="Parameter"/>
        <zeroOrMore>
          <ref name="File"/>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="File">
    <element name="file">
      <ref name="FileContent"/>
    </element>
  </define>
  <define name="FileContent">
    <interleave>
      <optional>
        <attribute name="size">
          <data type="positiveInteger"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="fmt">
          <data type="string"/>
        </attribute>
      </optional>
      <attribute name="origName">
        <data type="string"/>
      </attribute>
      <text/>
    </interleave>
  </define>
</grammar>
